Computer Science, asked by adityajaiswal0306200, 1 month ago

Write a program in JAVAto input any three different single digit numbers between 1 and 9 and display the greatest three digit number Example Input 4, 5, 3 Output Greatest number 543​

Answers

Answered by SabrinaHaque
0

Answer:

import java.util.Scanner;

public class Exercise39 {

public static void main(String[] args) {

int amount = 0;

for(int i = 1; i <= 4; i++){

for(int j = 1; j <= 4; j++){

for(int k = 1; k <= 4; k++){

if(k != i && k != j && i != j){

amount++;

System.out.println(i + "" + j + "" + k);

}

}

}

}

System.out.println("Total number of the three-digit-number is " + amount);

}

}

Attachments:
Answered by Ace0615
0

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args)

{

Scanner in= new Scanner (System.in);

System.out.println("Enter three one digit numbers");

byte a= in.nextByte();

byte b= in.nextByte();

byte c= in.nextByte();

if ((a<=9 && a>=0) && (b<=9 && b>=0) && (c<=9 && c>=0))

{

int x= Math.max (a,(Math.max(b,c)));

int y= Math.min (a,(Math.min(b,c)));

int z= (a+b+c)-(x+y);

System.out.print("Greatest no. formed: "+x+z+y);

}

else

{

System.out.print("Invalid Input");

}

}

}

Attachments:
Similar questions