PDA

Click to See Complete Forum and Search --> : Java Application Help


JavaBeginner
Feb 13th, 2010, 05:18 PM
I have an assignment and I am stuck. Can someone help?

Here is the assignment:
Write a Java program that reads an integer and checks whether it is even.

If your input is 25, your output should be:

Is 25 even?

false

If your input is 2000, your output should be:

Is 2000 even?

true

Also, the program must check if the number the user entered is between 1 and 1000.

If your input is 25, your output should be:

The number 25 between 1 and 1000 is true.

If your input is 2000, your output should be:

The number 2000 between 1 and 1000 is false.

1.The input and output must use JOptionPane dialog and display boxes.

HERE IS WHAT I HAVE SO FAR:


/* Assignment2.java
* Created on __13Feb2010__
*Checks for Even or Odd and between 1 to 1000*/
import javax.swing.JOptionPane;

public class Assignment2
{

public static void main(String[] args)
{
while (true)

String ans;
ans = JOptionPane.showInputDialog(null, "Please input an integer: ");
int n = Integer.parseInt(inputValue);
{if("Is " + n + " even? ");
if(((n%2)==0));
if("The number " + n + " between 1 and 1000 is ");
if(((n>=1) && (n<=1000)));

{
JOptionPane.showMessageDialog(null, answer);
}

}

}//end main()

}//end class Assignment2

Thanks to anyone that can help.