Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Plz help I am not understanding why my output not coming out like this on the console... Welcome to Hi-Lo guessing game!!! Enter your guess:
Plz help I am not understanding why my output not coming out like this on the console...
Welcome to Hi-Lo guessing game!!!
Enter your guess: 50
Guess is High
Enter you guess: 25
Guess is low
Enter you guess: 35
Guess is low
Enter you guess: 45
Guess is High
Enter you guess: 43
Guess is High
Enter your guess:42
Guess is High
Enter your guess: 40
Guess is low
Enter your guess: 41
You guessed the number in 8 attempts
eclipse-workspace - GuessAName/src/GuessANumber.java - Eclipse IDE 8 = 3 = 0 Outline Package Explorer X Guess Name EJRE System Library JavaSE-13] snc default package GuessANumber.java Guass Number.java 1e import java.util. Random; 2 import java.util.Scanner; 3 public class Guess ANumber { GuessANumber main(String[]) : void 50 public static void main(String[] args) { System.out.println("Welcome to Hi-Lo guessing game!!!"); int secret_number, guess; Random ran = new Random(); int attempts = 0; secret_number = ran.nextInt(100)+1; Scanner scan = new Scanner(System.in); System.out.print("Enter your guess : "); guess = scan.nextInt(); attempts++; if(guess secret_number) System.out.println("Guess is High"); Console X DE BARBED GuessANumber 1) (Java Application/Library/JavaJavavirtual Machinasijdk-13.0.2.jdk/Contents/Home/hinyjava (Feb 20, 2020, 8:52:43 AM Welcome to Hi-Lo guessing game!!! Enter your guess : 1971 af 340M eclipse-workspace - GuessAName/src/GuessANumber.java - Eclipse IDE 8 = 3 Guass Numberjava X = 0 Outline Package Explorer X Guess Name EJRE System Library JavaSE-13] snc default package GuessANumber.java int attempts = a; GuessANumber main(String[]) : void secret_n unber = ran.nextInt(100)+1; Scanner scan = new Scanner(System.in); do System.out.print("Enter your guess : "); guess = scan.nextInt (); attempts++; if(guess secret_number) System.out.println("Guess is High"); }whilelquess != secret_number); scan.close(); System.out.println("You guessed the number in "+attempts" attenpts"); 43 45 Console X DE BARBED GuessANumber 1) (Java Application/Library/JavaJavavirtual Machinasijdk-13.0.2.jdk/Contents/Home/hinyjava (Feb 20, 2020, 8:52:43 AM Welcome to Hi-Lo guessing game!!! Enter your guess : 2011 af 340MStep 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