India Languages, asked by 201718eee41, 1 year ago

Write a program to read a number of any length. Perform addition and subtraction on the largest and smallest digits.

Answers

Answered by Rumi123456789
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);
}
}
Similar questions
English, 7 months ago