subject

Fill in the missing code: this recursive method returns "even" if the length of a give string is even, and "odd" if the length of the string is odd.

public static string foo(string s)

{

if (s. length() ==0)
return "even";
else if (s. length() = = 1)
return "odd";
else

//your code goes here

}

(40 pts) you coded the following in the file test. java :
system. out. println( foo(5));
//more code here

public static int foo(int n) //line 9

{

if (n = = 0)
return 1;
else

system. out. println(n* foo(n-1) );

} //line 15

at compile time, you get the following error:
text. java: 15: missing return statement

} //line 15

^

1 error

explain what the problem is and how to fix it.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, KrishnaBalaram1235
To hide gridline when you display or print a worksheet
Answers: 1
image
Computers and Technology, 22.06.2019 18:40, penelopymorales24
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
image
Computers and Technology, 22.06.2019 20:30, fickllyd000
In this lab, you complete a prewritten c program that calculates an employee’s productivity bonus and prints the employee’s name and bonus. bonuses are calculated based on an employee’s productivity score as shown below. a productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Answers: 3
image
Computers and Technology, 23.06.2019 02:00, deeknuk
What is the main benefit of minimizing the ribbon in word? more options will be accessible through customized keystrokes. more of the document will be viewable without needing to scroll. fewer controls will be accessible to the user by using the mouse. fewer editing options will be available without entering a password.
Answers: 1
You know the right answer?
Fill in the missing code: this recursive method returns "even" if the length of a give string is ev...

Questions in other subjects: