when I put a number that is lower than the number I am supposed to get, it tells me "Too high, try again"
how can I fix this so that the message will tell me that the number is lower than what its supposed to be ?
For example :
program gives me number 392
I put 391
and it tells me number is too high, try again
import java.util.Random;
import javax.swing.JOptionPane;
public class
{
public static void main(String [] args)
{
Random randomNumbers = new Random();
int num = 1 + randomNumbers.nextInt(1000);
System.out.println(num);
String a =
JOptionPane.showInputDialog("Guess a number between 1 and 1000? ");
int b = Integer.parseInt(a);
String message;
if(num > B)/> {
message = "Too high, try again.";
} else if(num < B)/> {
message = "Too low, try again.";
} else if (num==B)/>{
message = "You're right, the number is" + num ;
message = "You guessed" + "times";
}
else{message= "wrong number";}
JOptionPane.showMessageDialog(null, message);
}
}

New Topic/Question
Reply



MultiQuote





|