/* a java program to check your math skills!! This program was a suggested program from Xiangming (Simon) to attempt to learn the skills of if statements and also to learn how to apply the conversion of a string to a integer (through the use of the Integer.parseInt method). I took this suggestion one step further by adding the four different checks of the math skills. What I like about the program is that once you have the basic comparison with the if else (a flow control) figured out, then you only need to replicate the statements with minor changes to get further comparisons. What I would like to figure out further is how to make the comparisons all show up in one dialog box. The complication is in how to make all of the comparisons in the if statement (some kind of multiple if statement) with all the right or wrong statements showing up appropriately. */ public class Comparer { public static void main (String args []) { //first number to be entered by user String firstNumber; int number1; //second number to be entered by user String secondNumber; int number2; //third number to be entered by user String thirdNumber; int number3; //sum of the addition int sum; // difference of the subtraction int difference; // result of the multipication int result; // product of the division int product; //read the first number as string firstNumber = javax.swing.JOptionPane.showInputDialog ("Enter first integer"); //read the second number as string secondNumber = javax.swing.JOptionPane.showInputDialog ("Enter second integer"); //read the third number as string thirdNumber = javax.swing.JOptionPane.showInputDialog ("Enter second integer"); //convert the numbers from type String to type int number1 = Integer.parseInt (firstNumber); number2 = Integer.parseInt (secondNumber); number3 = Integer.parseInt (thirdNumber); //add the first two numbers sum = number1 + number2; difference = number1 - number2; result = number1 * number2; product = number1 / number2; if (sum == number3) javax.swing.JOptionPane.showMessageDialog (null, "Your total of " + number3 + " was correct for adding " + number1 + " summed with " + number2 + "."); else javax.swing.JOptionPane.showMessageDialog (null, "Adding " + number1 + " and " + number2 + " does not equal the value of " + number3 + "."); if (difference == number3) javax.swing.JOptionPane.showMessageDialog (null, "Your total of " + number3 + " was correct for subtracting " + number2 + " from " + number1 + "."); else javax.swing.JOptionPane.showMessageDialog (null, "Subtracting " + number2 + " from " + number1 + " does not equal the value of " + number3 + "."); if (result == number3) javax.swing.JOptionPane.showMessageDialog (null, "Your total of " + number3 + " was correct for multiplying " + number1 + " and " + number2 + " together."); else javax.swing.JOptionPane.showMessageDialog (null, "Multiplying " + number1 + " times " + number2 + " does not equal the value of " + number3 + "."); if (product == number3) javax.swing.JOptionPane.showMessageDialog (null, "Your total of " + number3 + " was correct for dividing " + number1 + " with " + number2 + "."); else javax.swing.JOptionPane.showMessageDialog (null, "Dividing " + number1 + " by " + number2 + " does not equal the value of " + number3 + "."); } }