Thursday, 29 October 2015

Simple Java Addition Program

Simple Java Addition Program 

package ex1;

import javax.swing.JOptionPane;

public class Addition {

public static void main(String[] args)
{
JOptionPane.showMessageDialog(null,"This is a Simple Addition Example \n Click OK to Continue");

String a_value = JOptionPane.showInputDialog("Enter the Value of A");
String b_value = JOptionPane.showInputDialog("Enter the value of B");
//converting String to Integer
int a = Integer.parseInt(a_value);
int b = Integer.parseInt(b_value);

int result = a+b;

//Converting Integer to String
String result_val = "" + result;

JOptionPane.showMessageDialog(null, "the value of A + B is \n" + result_val +"\n Thankyou");

}

}


Output..