An Addition program in Java Programing Language.
Write this program in Java environment and run it.
import javax.swing.JOptionPane;
public class Addition {
public static void main(String[] args) {
String firstnumber;
String secondnumber;
int number1;
int number2;
int sum;
firstnumber=JOptionPane.showInputDialog("Enter first number");
secondnumber=JOptionPane.showInputDialog("Enter second number");
number1 = Integer.parseInt( firstnumber );
number2 = Integer.parseInt(secondnumber);
sum = number1 + number2;
JOptionPane.showMessageDialog(null , "The sum is "+sum, "Results", JOptionPane.PLAIN_MESSAGE );
System.exit(0);
}
}
Write this program in Java environment and run it.
import javax.swing.JOptionPane;
public class Addition {
public static void main(String[] args) {
String firstnumber;
String secondnumber;
int number1;
int number2;
int sum;
firstnumber=JOptionPane.showInputDialog("Enter first number");
secondnumber=JOptionPane.showInputDialog("Enter second number");
number1 = Integer.parseInt( firstnumber );
number2 = Integer.parseInt(secondnumber);
sum = number1 + number2;
JOptionPane.showMessageDialog(null , "The sum is "+sum, "Results", JOptionPane.PLAIN_MESSAGE );
System.exit(0);
}
}
0 comments:
Post a Comment