What am I doing wrong here??
I have done this program, everything is working exempt the last if-statement, when i type in 0 as the first number, it continues to write in another number instead of just writing out Thank you.
import java.util.Scanner;
public class Uppgiftb {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("Write any numberl");
int a = reader.nextInt();
System.out.println("Write another number");
int b = reader.nextInt();
if (a > b) {
System.out.println(a + " is bigger than " + b);
} if (a < b) {
System.out.println(b + " is bigger than " + a);
} if (a==b) {
System.out.println("The numbers are the same");
} if (a==0) {
System.out.println("Thank you.");
}
Re: What am I doing wrong here??
It is because you never told it not to do the other thing. What I did(i fixed it on my computer) is use a if else statement were after the first number is typed if it equals to zero do this if not do this