Write a program, the user enters two number, asks its subtraction, and displays the calculation result with the message box.

Source: Internet
Author: User

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.

Related Article

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.