Question
Create a flowchart for this program. import java.util.Random ; import java.util.Scanner ; public class GuessGame1 { private static int numGenerate( int num) { Random rand
Create a flowchart for this program.
import java.util.Random; import java.util.Scanner; public class GuessGame1 { private static int numGenerate(int num) { Random rand = new Random(); return rand.nextInt(num) + 1; } private static int getUserInput(String msg){ System.out.print(msg); Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); return num; } private static boolean compareGuess(int num1, int num2){ if(num1> 10 && num1>num2){ System.out.println("Way too high!"); } else if(num1 > num2){ System.out.println("Too high!"); } else if(num1 < num2){ System.out.println("Too low!"); } else { System.out.println("Won!!"); } return num1 != num2; } private static void finalMessage(int num){ System.out.println("Number of guess: " + num); } public static void main(String args[]){ System.out.println("Welcome to the guessing game"); int n = 10000; int numToGuess = numGenerate(n); int i = 0; boolean choice = true; while(choice){ int userNumber = getUserInput("Enter your guess: "); choice = compareGuess(userNumber,numToGuess); i++; } finalMessage(i); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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