Create a program that chooses a random number between 1 and 100 and then prompts
ID: 3641900 • Letter: C
Question
Create a program that chooses a random number between 1 and 100 and then prompts the user for a guess. Compare the guess to the true answer, and print an appropriate statement based on the result(e.g. "Correct!" or "Too low!" or "Too High!"
Expand the range of results given to the user: Give the user a different message depending on how far away the guess was from the answer (for example, within 4 of the real answer, or from 5-10, 11-20, 21-35, 36-60, 60+). Thus the user might get a message such as, "Almost got it, but you were too low! or "You couldn't be more wrong! You were too low!"
This is java
Netbeans
Explanation / Answer
x=random(); BufferedReader Br=new BufferedReader(new InputStreamREader(System.in)) String a=br.readline(); int y=Integer.parseInt("a"); z=math.abs(y-x); if(z==0) system.out.println("correct!"); else if(zRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.