The program must accept three integers X, Y and Z as the input. The program must print the value having the largest tenth digit as the output. If multiple values have the largest tenth digit, then the program must print the largest value among them as the output.
Boundary Condition(s):
10 < X, Y, Z <= 10^8
Input Format:
The first line contains the value of X, Y and Z separated by spaces(s).
Output Format:
The first line contains the largest value based on the given conditions
Answers
Answer:
import java.io.*;
class largest
{
public static void main ( String args [] )
{
System. out. println (" Enter first number ") ;
int x = sc. nextInt ( );
System. out. println (" Enter second number ") ;
int y = sc. nextInt ( );
System. out. println (" Enter third number ") ;
int z = sc. nextInt ( );
int a, b, c = 0;
a = x % 100 ;
a = a / 10 ;
b = y % 100 ;
b = b / 10 ;
c = z % 100 ;
c = c / 10 ;
if ( a > b )
{
if ( a > c )
{
System. out. println (" The largest number is "+ a) ;
}
else
{
System. out. println (" The largest number is "+ c) ;
}
}
else if (b > c)
{
System. out. println (" The largest number is "+ b) ;
}
else
{
System. out. println (" The largest number is "+ c) ;
}
}
}