I have written my program to prompt the user to enter an integers and then print if the number is odd or even. It says build successful, but will not prompt for the information to be entered and print the data. I use Netbeans with the JDK bundle.
Please help. My code is below:
import java.util.Scanner;
public class OddOrEven
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int num1;//sets variable for entered number
System.out.println(" Enter one integer: " ); //prompt to enter number
num1 = input.nextInt();
if ( num1 % 2 == 0 )
System.out.printf(" %d is even ", num1 );
if ( num1 % 2 != 0 )
System.out.printf(" %d is odd ", num1);
}
}