Got that one now for another problem. At the end I want them to either enter an "y" or an "n". Depending on if they want to run the program again. I need help doing that.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The local variable y may not have been initialized
The local variable n may not have been initialized
The local variable a may not have been initialized
at Driver.main(Driver.java:10)
import java.util.Scanner;
import java.util.Random;
public class Driver
{
public static void main(String[] args)
{
int z;
Double a;
Double y = y;
Double n = n;
Scanner stdIn = new Scanner(System.in);
Random rand = new Random();
int x = rand.nextInt(100)+1;
do
{
System.out.println("Please guess a random number;");
z = stdIn.nextInt();
while(z != x)
{
if(z>x)
{
System.out.println("Too High. Guess Again:");
z = stdIn.nextInt();
}
else if(z<x)
{
System.out.println("Too Low. Guess Again:");
z = stdIn.nextInt();
}
System.out.println("Thats Correct!! To play again press y or n to exit.");
a = stdIn.nextDouble();
}
}while(a == y);
System.out.println("Thanks for playing!");
}
}