Computer Science, asked by pihu16, 1 year ago

Write a program in java to input three different single digit numbers between 1 and 9(both inclusive). Display the greatest and smallest three digit number. Sample input: 2 , 7, 4 Sample output: greatest no.= 742 Smallest no.=247

Answers

Answered by Vintage
99
import java.util.Scanner;
public class Extra
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int a,b,c,d,e,f;
System.out.print("Enter the number:- ");
a=sc.nextInt();
System.out.print("Enter the number:- ");
b=sc.nextInt();
System.out.print("Enter the number:- ");
c=sc.nextInt();
d=Math.max(a,Math.max(b,c));
e=Math.min(a,Math.min(b,c));
f=(a+b+c)-(d+e);
System.out.println("Largest Number: "+(d*100+f*10+e));
System.out.println("Smallest Number: "+(e*100+f*10+d));
}
}

Vintage: hope it helps u
Vintage: its shorter then the above one and very efficient and understandable too....
Vintage: for further query on this plz lv a comment
pihu16: TYSM!!
Vintage: wlcm
Answered by shirisha1981
15

Answer:import java.util.Scanner;

public class Extra

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

int a,b,c,d,e,f;

System.out.print("Enter the number:- ");

a=sc.nextInt();

System.out.print("Enter the number:- ");

b=sc.nextInt();

System.out.print("Enter the number:- ");

c=sc.nextInt();

d=Math.max(a,Math.max(b,c));

e=Math.min(a,Math.min(b,c));

f=(a+b+c)-(d+e);

System.out.println("Largest Number: "+(d*100+f*10+e));

System.out.println("Smallest Number: "+(e*100+f*10+d));

}

}

Read more on Brainly.in - https://brainly.in/question/2179468#readmore

Similar questions
Math, 1 year ago