ICSE Class 9 Computer Applications
Question 5 of 16
Mathematical Library Methods — Question 5
Back to all questions 5
Question Question 5
Write a program in Java to find the minimum of three numbers using Math.min() method.
import java.util.Scanner;
public class KboatSmallestNumber
{
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();
int s = Math.min(a, b);
s = Math.min(s, c);
System.out.println("Smallest Number = " + s);
}
}Output
