Computer Science, asked by sahilthakkar2706, 1 year ago

How to write a java program for scanner class of addition?​

Answers

Answered by Anonymous
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
sahilthakkar2706: I am sorry for not making ur answer brainliest.....as the second one helped me more
Anonymous: ok
Anonymous: welcome
Answered by suneelgoli
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