Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Icdt 88 2nd International Conference On Database Theory Bruges Belgium August 31 September 2 1988 Proceedings Lncs 326

Authors: Marc Gyssens ,Jan Paredaens ,Dirk Van Gucht

1st Edition

3540501711, 978-3540501718

Students also viewed these Databases questions