Question: Guess my number program Java I have an error with the count. Also, I don't know how to make a while loop that keeps the
Guess my number program Java
I have an error with the count. Also, I don't know how to make a while loop that keeps the game going till you guess the number.
import java.util.Random;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String inputString = scan.nextLine();
System.out.println(inputString);
int inputInt = scan.nextInt();
System.out.println(inputInt);
count++;
Random rand = new Random();
int newNumber = rand.nextInt(101);
System.out.println("The number was " + newNumber);
scan.close();
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
