This is my first post in this forum and i have no idea how to post code in the format that other people post it.
This is my first little program that i wrote after reading a couple of chapters in a book and looking at some tutorials but sadly it doesnt work.
Every time one puts in a smaller number it still says that the number is smaller even though its supposed to be bigger
I also tried using the Random number generator but it fails either way..
Would be happy if anyone could help
import java.util.*;
public class Apple {
public static void main(String[] args) {
Scanner A = new Scanner(System.in);
int realNumber = 55;
System.out.println("Enter an integer between 0 and 100");
int userNumber = A.nextInt();
while(userNumber != realNumber){
if( userNumber > realNumber){
System.out.println("Its less then " +userNumber);
System.out.println("Please enter another number");
}
if( userNumber < realNumber){
System.out.println("Its less then " +userNumber);
System.out.println("Please enter another number");
}
else{
System.out.println("The number is invalid");
System.out.println("Please enter another number");
}
userNumber = A.nextInt();
}
System.out.println("The number is correct");
}
}