mardi 25 juillet 2017

Entering different possible integers to get if-statement in Java

import java.util.Scanner;

public class MyFirstJavaProgram3 {

public static void main(String[] args) {

    System.out.println("Enter A Number From 1 - 9");
    Scanner scan = new Scanner (System.in);
    int number = scan.nextInt();

    if (number  ) 
    { 
        System.out.println("NOICE");
    }

    else
    {
        System.out.println("Please Enter Value Between 1 and 9");
    }

}

}

I'm fairly new to Java and wondering what I would have to put in the if statement to make it say "NOICE" when a number between 1 and 9 is typed by the user. What code would I have to use?

Aucun commentaire:

Enregistrer un commentaire