1 Packagedemo;2 //An addition program3 4 ImportJavax.swing.JOptionPane;//Import Class Joptionpane5 6 Public classaddition {7 Public Static voidMain (String args[])8 {9String Firstnumber,//First string entered by userTenSecondnumber;//second string entered by user One intNumber1,//First number to add ANumber2,//second number to add - Sum, -Cha,ji,shang;//sum of number1 and Number2 the - //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 = AJoptionpane.showinputdialog ("Enter Second integer" ); at - //convert numbers from type String to type int -Number1 =Integer.parseint (firstnumber); -Number2 =Integer.parseint (secondnumber); - - //Add the numbers insum = Number1 +number2; -Cha = number1-number2; toJi = number1 *number2; +Shang = (number1/number2) + (number1%number2); - the //Display the results * Joptionpane.showmessagedialog ( $ NULL, "The sum is" +sumPanax Notoginseng+ "\ n" + "The CHA is:" +Cha -+ "\ n" + "The JI is:" +ji the+ "\ n" + "The Shang is:" +Shang + ); A theSystem.exit (0);//Terminate The program + } -}
Letter 1403-2 Class 20142897 Huaiyuan after class first question