Ok so here is what I have and I am stuck. It is not recognizing whether a number is even or odd. So where do I need to put the remainder operator so that it will recognize if a number is even or odd?
import javax.swing.JOptionPane; // program uses JOptionPane
public class EvenOdd {
/** Creates a new instance of EvenOdd */
public EvenOdd() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String Number; // string entered by user
String result; // a string containing the output
int number; // number to be read
int even; // number if even
int odd; // number if odd
// read number from user as a string
Number = JOptionPane.showInputDialog( null, " Enter a number" );
// convert number from type String to type int
number = Integer.parseInt( Number );
// initialize result to empty String
result = "";
if ( number%2 == 0/2 );
result = result + Number + " is EVEN ";
// Display results
JOptionPane.showMessageDialog( null, result, " Results ", JOptionPane.INFORMATION_MESSAGE );
System.exit ( 0 ); // terminate application
if ( number%2 != 0/2 );
result = result + Number + " is ODD ";
// Display results
JOptionPane.showMessageDialog( null, result, " Results ", JOptionPane.INFORMATION_MESSAGE );
System.exit ( 0 ); // terminate application
} // end method main
} // end class EvenOdd