I am having a problem with my program and I need some help. Anything would be greatly appreciated. I am running a guessing game.
Syntax error, insert "while ( Expression ) ;" to complete DoStatement
Syntax error, insert "}" to complete MethodBody
Here is my code:
import java.util.Scanner;
import java.util.Random;
public class Driver
{
public static void main(String[] args)
{
int z;
Double answer;
Double y;
Double n;
Scanner stdIn;
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!! Play again y or n?");
answer = stdIn.nextDouble();
}
}while(answer == y);
System.out.println("Thanks for playing!");
}
}
Syntax error, insert "while ( Expression ) ;" to complete DoStatement
Syntax error, insert "}" to complete MethodBody
Here is my code:
import java.util.Scanner;
import java.util.Random;
public class Driver
{
public static void main(String[] args)
{
int z;
Double answer;
Double y;
Double n;
Scanner stdIn;
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!! Play again y or n?");
answer = stdIn.nextDouble();
}
}while(answer == y);
System.out.println("Thanks for playing!");
}
}