# Problems with a "if-then and if-then-else" statements

• October 7th, 2012, 12:10 AM
jjd712
Problems with a "if-then and if-then-else" statements
Code :

```import java.util.*; import java.io.*; public class TEster {   /** * @param args */ public static void main(String[] args) { int x; char Guess; Scanner Number_input = new Scanner( System.in ); System.out.println("Enter a number: "); x = Number_input.nextInt(); if (x >=50) { Guess = 'Y'; } else if (x <=50) { Guess = 'N'; System.out.print("Number:" + Guess); }       }     }```

Why won't Y or N print when i enter a number? I can input a number but after that nothing happens, Y or N should print for "Guess" right?
• October 7th, 2012, 12:31 AM
Actinistia
Re: Problems with a "if-then and if-then-else" statements
Code java:

```import java.util.*; import java.io.*; public class TEster {   /** * @param args */ public static void main(String[] args) { int x; char Guess; Scanner Number_input = new Scanner( System.in ); System.out.println("Enter a number: "); x = Number_input.nextInt(); if (x >=50) { Guess = 'Y'; } else if (x <=50) { Guess = 'N'; System.out.print("Number:" + Guess); } } }```

If you look at your if/else if statement, you'll see your problem. What happens when you enter a number higher than 50? What happens when you enter a number lower than 50? What happens when you enter 50 itself? I suggest reading The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics) for more info about it.