ADDITION IN JAVA BY SCANNER AND FRAME
import javax.swing.JOptionPane;
import java.util.Scanner;
public class Both {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
String n;
int a,b,c;
n=JOptionPane.showInputDialog("Enter a");
a=Integer.parseInt(n);
System.out.print("Enter b:");
b=input.nextInt();
c=a+b;
JOptionPane.showMessageDialog(null, "Sum of "+a+" and "+b+"="+c);
}
}
0 Comments