The program performs the following actions: The difference between the programs
ID: 3614465 • Letter: T
Question
The program performs the following actions:
The difference between the programs in Part 1 and Part 2 is thatnow the program repeatedly asks the user if he/she wantsto play a game; if the user enters anything but 'y', the programterminates; otherwise the program allows the user to play a gamebefore asking again if the user wants to play another game.
Number of guesses Message 1 That was lucky! 2-4 That was amazing! 5-6 That was really good! 7 That was ok! 8-9 That was pretty bad! 10 or more This is not your game!Explanation / Answer
please rate - thanks this is part 2. to make it part 1 getrid of the red lines of code import java.util.*; public class Lab4Part2{ public static voidmain(String [] args) { int number; int guess; int guesses; int over; char torf; Scanner Keyboard=newScanner(System.in); do { int num=(int)(100 * Math.random ()) + 1;; guesses=0; over=0; do { System.out.println("Guess a number between 1 and 100."); guess=Keyboard.nextInt(); guesses++; if (guessnum) { System.out.println("Your guess is too high."); } else {System.out.println("You got it in "+guesses+" guesses"); if(guesses>=10) System.out.println("This is not your game"); else if(guesses>=8) System.out.println("That was pretty bad!"); elseif(guesses==7) System.out.println("That was ok!"); else if(guesses>=5) System.out.println("That was really good!"); else if(guesses>=2) System.out.println("That was amazing!"); else System.out.println("That was lucky!"); over=1; } }while(over==0); System.out.println("Would youlike to play again (y/n)? "); torf=Keyboard.next().charAt(0); }while(torf=='y'||torf=='Y'); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.