In Java, how would i be able to change an int value?
I am writing a small program where the user has to guess a number. I want
them to type in the number that they are guessing and then it would change
the value of an int. How would I change the value of X to what the user
types in? This is what I have so far:
public static void main(String[] args) {
Scanner textIn = new Scanner(System.in);
System.out.println("Try to guess what number I am thinking of.");
//X is the int I want to change
int x = 100;
//Z is the one I am comparing x to
int z = 10;
String zGuess = textIn.nextLine();
boolean xTest = true;
{
if (x == z);
System.out.println("You guessed right!");
}
//XTEST PART ONE
while (x < z) {
System.out.println("X < Z");
break;
}
//XTEST PART TWO
while (x > z) {
System.out.println("X > Z");
break;
}
}
No comments:
Post a Comment