Write a program to addition of two numberWrite a program to add two number which is input by user
and display them addition.
For Example:
A=10
B=20
C= A+B
ALGORITHM:-
step 1 : Start
step 2 : import java.io.* Package
step 3 : Create A class
step 4 : Define the main method
step 5 : Input Two Number from user
step 6 : Add these Number And Stored in Third Variable
step 7 : Print the Third Variable
step 8 : Terminate
PROGRAM CODE:-
import java.io.*;
class addition
{
public static void main(String rags[])
{
Console con=System.console();
int a,b,c;
//Take the input from user
System.out.println("Enter First Number: ");
a=Integer.parseInt(con.readLine());
System.out.println("Enter Second Number: ");
b=Integer.parseInt(con.readLine());
c=a+b;
System.out.println("Sum of two number is: "+c);
}
}
OUTPUT:-
Enter First Number: 45
Enter Second Number: 23
Sum of two Number is: 68
Java Program to Add two number which is input by user How to take input in java programming Addition of two number using Console class How to input Integer value in java
ConversionConversion EmoticonEmoticon