Write a program, the user input two number, to find out its subtraction, and the message box to display the calculation results.
Source Code :
Import Javax.swing.JOptionPane;
public class Operation {
public static void Main (string[] args) {
TODO auto-generated method stubs
String Firstnumber,secondnumber;
int number1,number2,sum,minus,multiply,divide;
read the first number of inputs
Firstnumber =joptionpane.showinputdialog ("Input first number");
read the second number of inputs
Secondnumber =joptionpane.showinputdialog ("Enter a second number");
implementation Operations
Number1 = Integer.parseint (Firstnumber);
Number2 = Integer.parseint (Secondnumber);
Arithmetic Numbers
sum = number1 + number2;
Minus=number1-number2;
Multiply=number1*number2;
Divide=number1/number2;
Show Results
Joptionpane.showmessagedialog (NULL, " and as :" +sum+ "The difference is:"+minus+ " product is: "+multiply+" quotient:"+divide," Results ", joptionpane.plain_message);// Display results on a window
System.exit (0);// free space
}
}
The results show:
Write a program, the user enters two number, asks its subtraction, and displays the calculation result with the message box.