Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // HW
- import java.util.Scanner;
- public class ThreeDigitNumber {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- int num, hundreds, tens, ones;
- System.out.println("Enter a 3 digit number:");
- num = in.nextInt();
- hundreds = Math.abs(num) / 100;
- tens = (Math.abs(num) - 100 * hundreds) / 10;
- ones = Math.abs(num) - 100 * hundreds - 10 * tens;
- int MaxNum = Math.max(hundreds, Math.max(tens, ones));
- int MinNum = Math.min(hundreds, Math.min(tens, ones));
- int MidNum = ones + tens + hundreds - MaxNum - MinNum;
- System.out.println("The order of the digits from biggest to smallest is: " + MaxNum + ", " + MidNum + ", " + MinNum + ".");
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment