Write a java program to input the sum of two numbers and its difference with using scanner class
Answers
Answered by
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);
}
}
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