Question: The following program guesses the hidden number known by the user. Write code in place of XXX that completes the recursive function? import java.util.Scanner; public
The following program guesses the hidden number known by the user. Write code in place of XXX that completes the recursive function?
import java.util.Scanner;
public class GuessNumber
public static void guessNumberint lowVal, int highVal
int midVal;
char userAnswer;
midVal highVal lowVal;
System.out.printIs it midVal lhy: ;
Scanner scanner new ScannerSystemin;
userAnswer scanner.nextcharAt;
if userAnswer l && userAnswer h
System.out.printlnThank you!";
else
XXX
else
guessNumbermidVal highVal;
public static void mainString args
int lowVal ;
int highVal ;
guessNumberlowVal highVal;
Why did you need to write that code the way you did? Explain this as comments in your code.
int main
cout "Choose a number from to endl;
cout "Answer with:" endl;
cout l your num is lower endl;
cout h your num is higher endl;
cout any other key guess is right endl;
GuessNumber;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
