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
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));
}
}
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
Answered by
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