Math, asked by jinoorjahan77, 4 months ago

write a program in java to input three numbers and display the smallest number use maths.min and math.max method

Answers

Answered by raghvendrark500
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