Question: The language code is Java. Here is the source codes for both: 1. The following program prompts the user to enter his or her name,

 The language code is Java. Here is the source codes for

The language code is Java. Here is the source codes for both:

1. The following program prompts the user to enter his or her name, and then a number. A for loop is then used to echo back the users name the given number of times:

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

Scanner keyedInput = new Scanner(System.in);

// Declare variables

int num; String name;

// Get the users name

System.out.println("Please enter your name:"); name = keyedInput.nextLine();

// Get the users age

System.out.println("Please enter a number:"); num = keyedInput.nextInt();

System.out.println("----------------");

// Print out the users name, num times, where num is the user's age

for (int i = 1; i

{ System.out.println(name); }

for (int i = 1; i

{ System.out.println(name); }

2. 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);

Program Control and Flow Charts . Your task is to create two flow charts, one for each of the following: A program that prompts the user to enter their name, and then a number. A for loop is then used to echo back the user's name the given number of times. 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 source code for both of these programs is available above, in the activity. Your task is to take the source code and create the flow charts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!