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
Write the Java expression for the following:
Write a program to print:
i. p to the power q
ii. the square root of pThe values of p and q are 64 and 2 respectively.
Write a program to generate random integers in the range 10 to 20.
Write valid statements for the following in Java:
i. Print the rounded off value of 234.49
ii. Print the absolute value of -9.99
iii. Print the largest of -45 and -50
iv. Print the smallest of -56 and -57.4
v. Print a random integer between 50 and 70
vi. Print 10.5 raised to the power 3.8