How to write a java program for scanner class of addition?
Answers
Answered by
1
Explanation:
Java program to add two numbers
import java.util.Scanner;
class AddNumbers.
{
public static void main(String args[])
{
int x, y, z;
System. out. println("Enter two integers to calculate their sum");
Scanner in = new Scanner(System. in);
sahilthakkar2706:
thanks a lot
Answered by
1
Answer:
import java.util.Scanner;
class AddNumbers
{
public static void main(String args[])
{
int x, y, z;
System.out.println("Enter two integers to calculate their sum");
Scanner in = new Scanner(System.in);
x = in.nextInt();
y = in.nextInt();
z = x + y;
System.out.println("Sum of the integers = " + z);
}
}
output:
5
6
Sum of the integers =11
Similar questions
Hindi,
6 months ago
English,
6 months ago
Physics,
1 year ago
Hindi,
1 year ago
Political Science,
1 year ago
Political Science,
1 year ago