input 3 digit number and print the highest number

simple way…

import java.util.Scanner;

class Main{
 public static void main(final String args[]) {

 final Scanner in = new Scanner(System.in);

 int a, b, c;
 System.out.print("Enter 3 digit number :");
 int num = in.nextInt();

 a = num / 100;
 b = (num / 10) % 10;
 c = num % 10;

 if (a > b && a > c) {
  System.out.print("Largest number is:"+a);
 } else if(b > c) {
  System.out.print("Largest number is:"+b);
  } else {
   System.out.print("Largest number is:"+c);
  }
 }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top