Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

Find the area between the parabolas y = 2x 2 + 1 and y = x 2 + 5.

Answered: 1 week ago