|
-
October 1st, 1999, 11:12 AM
#1
Reading odd and even integers
I'm trying to write a program in for school that will read whether a number is odd or even, and I just can't get anything to work.
I'm guessing I need if statements but I can't figure out exactly what, this is what I have so far...
import javax.swing.JOptionPane;
public class Even {
public static void main (String args[])
{
String num1;
int n1,odd,even;
num1 = JOptionPane.showInputDialog("Please type in an integer:");
n1 = Integer.parseInt(num1);
odd = ? ;
even = ? ;
if( ? )JOptionPane.showMessageDialog(
null,"The number is "+odd,"Results",JOptionPane.INFORMATION_MESSAGE);
else JOptionPane.showMessageDialog(
null,"The number is "+even,"Results",JOptionPane.INFORMATION_MESSAGE);
System.exit (0);
}
}
The ?'s are where I', completely lost, someone Please help!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|