Program to addition of two number given by user in java programming:
import java.lang.*;
import java.io.*;
import java.util.*;
class Sum2numDemo
{
public static void main(String args[])
{
int num1,num2,result;
Scanner s=new Scanner(System.in);
System.out.println("a3programming.blogspot.com");
System.out.println("Enter number 1:");
num1=s.nextInt();
System.out.println("Enter number 2:");
num2=s.nextInt();
result=num1+num2;
System.out.println("Result :"+result);
}
}
Expected output is:
import java.lang.*;
import java.io.*;
import java.util.*;
class Sum2numDemo
{
public static void main(String args[])
{
int num1,num2,result;
Scanner s=new Scanner(System.in);
System.out.println("a3programming.blogspot.com");
System.out.println("Enter number 1:");
num1=s.nextInt();
System.out.println("Enter number 2:");
num2=s.nextInt();
result=num1+num2;
System.out.println("Result :"+result);
}
}
Expected output is:
0 Comments