Java Subtraction message box display results

Source: Internet
Author: User

Import Javax.swing.JOptionPane; Import Class Joptionpane

public class Operation {
An addition program


public static void Main (String args[])
{
String Firstnumber,//First string entered by user
Secondnumber; Second string entered by user
int Number1,//first number to add
Number2,//second number to add
Sum,//Sum of Number1 and number2
DIF,//difference of number1 and number2
Pro,//product of Number1 and Number2
Cou Cousuit of Number1 and Number2
Read in first number from user as a string
Firstnumber =
Joptionpane.showinputdialog ("Enter first integer");

Read in second number from user as a string
Secondnumber =
Joptionpane.showinputdialog ("Enter second integer");

Convert numbers from type String to type int
Number1 = Integer.parseint (Firstnumber);
Number2 = Integer.parseint (Secondnumber);

Add the numbers
sum = number1 + number2;
dif = Number1-number2;
Pro = Number1 * NUMBER2;
Cou = Number1/number2;
Display the results
Joptionpane.showmessagedialog (NULL,
"And for" + sum + "\ n" +
"Difference to" + dif + "\ n" +
"Product is" + pro+ "\ n" +
"The quotient is" + cou+ "\ n",
"Results",
Joptionpane.plain_message);

System.exit (0); Terminate the program
}

}

Java Subtraction message box display results

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.