Computer Science, asked by rampalrathour0pd1yi4, 1 year ago

Write a java program to input the sum of two numbers and its difference with using scanner class

Answers

Answered by AsutoshDikhit
11
import java.util.Scanner;
class Number
{
public static void main (String arg[])
{
Scanner sc = new Scanner (system.in);
int a,b,s,d;
System.out.print("Input two numbers= ");
a=sc.nextInt();
b=sc.nextInt();
s=a+b;
d=Math.abs(a-b);
System.out.print("The sum is= "+s+" and the difference is "+d);
}
}
Similar questions