Computer Applications

Write a program in Java to find the minimum of three numbers using Math.min() method.

Java

Java Math Lib Methods

60 Likes

Answer

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

Answered By

34 Likes


Related Questions