0

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);


}


}

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

Then you probably don't have the console view (or whatever netbeans calls it) open on netbeans. So it is probably producing the output but not showing it to you. I can tell by looking at your program that it works, but I ran it just in case, and it works fine on Eclipse.

Edited by BestJewSinceJC: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.