Write a program put the two number and find the sum of two number using Scanner class ( it means output windows add number)
Answers
Answered by
0
JAVA
Java is a machine independent language which can work on any platform.It is written within a class. The variable and functions are declared within a class.
Java is case sensitive language.
Package is the set of many classes.
The following programming us done by the io package of Java.
CODING
import Java. io. *;
class sum
{
public static void main(String args[])throws Exception
{
DataInputStream in= new DataInputStream(Syst em . in);
{
int a, b, s=0;
System . out . println("Enter any two nunbers");
a = Integer. parseInt(in . readLine());
b = Integer. parseInt(in . readLine());
s= a+ b;
Sy stem . out . println("The Sum is "+s);
}
}
Ou tput
a =15
b= 25
The sum is 40
Variable description
- int a = To store the value of first number inputed by the user.
- into b= To store the value of second number inputed by the user.
- int s =To store the sum of the two numbers inputed by the user
Similar questions