ok this is my current code
and it is right nothing wrong whatsoever. IT WORKS!
BUT
after reading my assignment carefully we werent supposed to use scanner but javaIO.* nd that is diff then what im used to
help me out ppl plz?
btw new to this forum and it rocks lol!
pretty much i need to use strings and readLines and stuff
but im really confused
any help would be great!
btw i am using ECLIPSE PLATFORM to run these scripts if that helps and im not allowed to use anything else
http://www.eclipse.org/
Code:
//I'm going to use these from now own. Help organize thoughts more for me.
import java.util.Scanner;
public class quadratic
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in); //this is 4 user input
int x = (int)(100 * Math.random()) + 1;
int inputnumber = 0; //this is the user input #
char answer;
int counter = 0;
boolean tf = true;
System.out.print("If you wnna play a game say yes otherwise say no: ");
String answer2 = kb.nextLine();
answer = answer2.charAt(0);
while (tf == true)
{
char answer3 = 'y'; //Compares yes and no answer from the user yepyep
if (answer != answer3)
{
System.out.println("Goodbye!");
tf = false;
}
else
{
System.out.println("\nI am thinking of a number between 1 and 100. Try to guess it.\n"); //and the guessing game starts!
while (x != inputnumber)
{
System.out.print("What's your guess? ");
inputnumber = kb.nextInt();
if (x < inputnumber)
{
System.out.println(inputnumber + " is too big!\n");
}
else if (x > inputnumber)
{
System.out.println(inputnumber + " 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;
}
}
}
}
}
and it is right nothing wrong whatsoever. IT WORKS!
BUT
after reading my assignment carefully we werent supposed to use scanner but javaIO.* nd that is diff then what im used to
help me out ppl plz?
btw new to this forum and it rocks lol!
pretty much i need to use strings and readLines and stuff
but im really confused
any help would be great!
btw i am using ECLIPSE PLATFORM to run these scripts if that helps and im not allowed to use anything else
http://www.eclipse.org/