Thans Alot... I've learn so much. But every time i got my code right now - it shows the answer two times, how can i make it go away?
Code:
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner userInput = new Scanner(System.in);
Random rand = new Random();
int userNumber = rand.nextInt(11);
int comNumber = rand.nextInt(11);
System.out.println("Your number is: " + userNumber + " / 10");
System.out.println("Do you think that YOUR NUMBER is Heigher(h), Lower(l) or Equal To(e), than the COMPUTER's NUMBER: ");
String letterInput = userInput.next();
if(letterInput.equalsIgnoreCase("h") && userNumber > comNumber){
System.out.println("You are right! ");
System.out.println("The computer's number is: " + comNumber);
}
if(letterInput.equalsIgnoreCase("l") && userNumber < comNumber){
System.out.println("You are right! ");
System.out.println("The computer's number is: " + comNumber);
}
if(letterInput.equalsIgnoreCase("e") && userNumber == comNumber){
System.out.println("You are right! ");
System.out.println("The computer's number is: " + comNumber);
}
else{
System.out.println("You are wrong! ");
System.out.println("The computer's number is: " + comNumber);
}
}