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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Ais a built in formula in spread spread a is any math process such as addition or subtraction. options are function and operation
Answers: 1
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
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
question
Mathematics, 16.11.2020 04:00
question
Mathematics, 16.11.2020 04:00
question
Mathematics, 16.11.2020 04:00
Questions on the website: 13722363