ICSE Class 10 Computer Applications
Question 64 of 76
Revising Basic Java Concepts — Question 68
Back to all questions 68
Question Question 45
Write a program to input three numbers and print the largest of the three numbers.
import java.util.Scanner;
public class KboatLargestNumber
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = in.nextInt();
System.out.print("Enter second number: ");
int b = in.nextInt();
System.out.print("Enter third number: ");
int c = in.nextInt();
System.out.print("Largest number: ");
if (a > b && a > c)
System.out.println(a);
else if (b > a && b > c)
System.out.println(b);
else
System.out.println(c);
}
}Output
