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
Step: 1
Creating a flowchart based on the provided code is a great way to visualize the programs logic Heres ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started