My project is as follows:
2. Modify the class NumberTest.java so that:
a) The user is prompted to enter an integer and a double and the following information is displayed:
a. adding the two number,
b. subtracting the double from the int, c. dividing the int by the double, d. dividing the int by 2, e. finding the remainder of the int divided by 2, and f. dividing the double by 2.
b) c) **Note the code to perform these steps can be placed within main().
The output is formatted so that only two decimal places are displayed. The comments are up-to-date with your information
So far my code is like this:
public static void main (String[] args)
{
JFrame frame = new JFrame ("Number Tester");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
NumberPanel panel = new NumberPanel();
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
double intNum;
double doubleNum;
/** Now use regular System.out and Scanner commands to prompt the user to
* enter the two numbers and then display the results. Again, the results
* should be formatted to two decimal places.
*/
Scanner sc = new Scanner(System.in); //creates new scanner
System.out.print("Enter an integer: "); //gets first number
intNum = sc.nextInt();
System.out.print("Enter a double: "); //gets second number
doubleNum = sc.nextDouble();
System.out.print(intNum + doubleNum + " ");
System.out.print(intNum - doubleNum + " ");
System.out.print(intNum / doubleNum + " ");
System.out.print(intNum / 2 + " ");
System.out.print(intNum % 2 + " ");
System.out.print(doubleNum / 2 + " ");
} //end main
} //end class