Question: The following program generates a random number between 1 and 5. A while loop then continuously prompts the user to guess the random number. The

The following program generates a random number between 1 and 5. A while loop then continuously prompts the user to guess the random number. The loop continues until the user guesses the number correctly.

// Create the scanner object to read input from the user

Scanner keyedInput = new Scanner(System.in);

// Declare variables

int randNum; int userGuess = 0;

// Generate a random number between 1 and 5

randNum = (int)(Math.round(Math.random()*5+1));

do { System.out.println("Enter a guess:"); userGuess = keyedInput.nextLine();

if (userGuess == randNum) { System.out.println("Yes, you got it!"); }

else { System.out.println("Sorry, try again!"); }

} while (userGuess != randNum);

Your task is to create A flow chart:

  • A program that generates a random number between 1 and 5. A do-while loop then continuously prompts the user to guess the random number. The loop continues until the user guesses the number correctly.
  • The flow chart is based upon the code above
  • I need help making the flow chart
  • Thank you to whoever is helping me, I really appreciate it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Creating a flowchart based on the provided code is a great way to visualize the programs logic Heres ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!