write a program in java to input three numbers and display the smallest number use maths.min and math.max method
Answers
Answered by
1
import java.util.Scanner;
public class Exercise1 {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input the first number: ");
double x = in.nextDouble();
System.out.print("Input the Second number: ");
double y = in.nextDouble();
System.out.print("Input the third number: ");
double z = in.nextDouble();
System.out.print("The smallest value is " + smallest(x, y, z)+"\n" );
}
public static double smallest(double x, double y, double z)
{
return Math.max(Math.max(x, y), z);
}
}
Similar questions
Math,
2 months ago
English,
2 months ago
Hindi,
4 months ago
Math,
4 months ago
India Languages,
10 months ago
India Languages,
10 months ago
India Languages,
10 months ago