Computer Science, asked by rashmim56, 9 months ago

Write a program in Java to input three numbers and display the greatest and the smallest of
the three numbers.
Hint: Use Math.min() and Math maxo
Sample Inpur: 87, 65, 34
Sample Output: Greatest Number 87
Smallest number 34​

Answers

Answered by arpitshukla10
4

Answer:

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.min(Math.min(x, y), z);

}

}

Answered by Vyomsingh
4

Answer:

class Great

{

void main(int a,Int b,int c)

{

int larg=Math.max(a,Math.max(b,c));

int small=Math.min(a,Math.min(b,c));

System.out.println("Greatest number:-"+larg);

System.out.println("Smallest number:-"+small);

}

}

Similar questions