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


}


}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.