Code:
//I'm going to use these from now own. Help organize thoughts more for me.
import java.io.*;
public class quadratic {
public static void main(String args[])
throws IOException {
BufferedReader IN = new BufferedReader (new InputStreamReader(System.in));
int x = (int)(100 * Math.random()) + 1;
int inputnumber = 0; //this is the user input #
int counter = 0;
double N2, z2;
String N;
System.out.print("Say 1 To Start Game, and 2 To Quit:\t");
N = IN.readLine ();
N2 = Integer.parseInt (N);
while (N2 == 2)
{
System.out.println("Goodbye!");
break;
}
while (N2 == 1)
{
System.out.println("\nI am thinking of a number between 1 and 100. Try to guess it.\n");
String z;
System.out.print("What's your guess? ");
z = IN.readLine ();
z2 = Integer.parseInt (z);
{
if (z2 > x)
{
System.out.println(z2 + " is too big!\n");
}
else if (z2 < x)
{
System.out.println(z2 + " is too small!\n");
}
counter = counter + 1;
}
if (counter == 1)
{
System.out.println("You've got it in " + counter + " guesses. That was lucky!");
System.out.print ("\n \n \n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
else if (counter >= 2 && counter <= 4)
{
System.out.println("You've got it in " + counter + " guesses. That was amazing!");
System.out.print ("\n \n \n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
else if (counter >= 5 && counter <= 6)
{
System.out.println("You've got it in " + counter + " guesses. That was really good!");
System.out.print ("\n \n \n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
else if (counter == 7)
{
System.out.println("You've got it in " + counter + " guesses. That was ok!");
System.out.print ("\n \n \n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
else if (counter >= 8 && counter <= 9)
{
System.out.println("You've got it in " + counter + " guesses. That was pretty bad!");
System.out.print ("\n \n\n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
else
{
System.out.println("You've got it in " + counter + " guesses. This is not your game!");
System.out.print ("\n \n \n \t \t \t \t \t \t \t \t \t \t BY Neel Vakharia");
break;
}
}
}
}
Thats my code
it works
but everytime i run it it duz wat i dotn want it to do
the number gets chosen randomly BUT when the user takes a guess at the number it says whether its to big or small rite BUT it ends it rite there and then it doesnt stop when the user guesses it rite it stops on the users first reply
btw: ECLIPSE PLATFORM is used to run these scripts