Write a program to read a number of any length. Perform addition and subtraction on the largest and smallest digits.
Answers
Answered by
0
BLUEJ PROGRAM :-
import java.util.Scanner;
public class Add_Subtract
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a,b,c,d,e;
System.out.println("Enter two numbers");
a=in.nextInt();
b=in.nextInt();
if (a>b || b>a)
c=(a+b);
System.out.println("The sum of those two numbers are : "+c);
else if(a>b)
d=(a-b);
System.out.println("The difference of the largest and smallest numbers are : "+d);
else
e=(b-a);
System.out.println("The difference of the largest and smallest numbers are : "+e);
}
}
import java.util.Scanner;
public class Add_Subtract
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a,b,c,d,e;
System.out.println("Enter two numbers");
a=in.nextInt();
b=in.nextInt();
if (a>b || b>a)
c=(a+b);
System.out.println("The sum of those two numbers are : "+c);
else if(a>b)
d=(a-b);
System.out.println("The difference of the largest and smallest numbers are : "+d);
else
e=(b-a);
System.out.println("The difference of the largest and smallest numbers are : "+e);
}
}
Similar questions
Math,
8 months ago
Accountancy,
8 months ago
Science,
1 year ago
Math,
1 year ago
Biology,
1 year ago