
write a program to input a number or find & print the highest digit.

import java.util.*;
class InputNumber
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter number: ");
int num=input.nextInt();
int largest=0;
while( num > 0 ){
int digit = num % 10;
num = num / 10;
if (digit > largest)
largest = digit;
}
System.out.println("Highest digit is: "+largest);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.