in .java
Write a program that asks the user to enter 3 grades and computes the minimum and the maximum of those 3 grades and prints it. Hint: Use the Math.min() and Math.max() methods. This program will compute the smallest and highest of 3 grades entered by the user.
Enter 3 grades separated by a space: 100 85.3 90.5
Smallest: 85.3
Highest: 100.0
Bye
//MINMAX3.java import java.util.Scanner; public class MINMAX3 { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); double n1, n2, n3; System.out.print("Enter 3 grades separated by a space: "); n1 = scnr.nextDouble(); n2 = scnr.nextDouble(); n3 = scnr.nextDouble(); System.out.println("Smallest: "+Math.min(Math.min(n1,n2),n3)); System.out.println("Highest: "+Math.max(Math.max(n1,n2),n3)); System.out.println("Bye"); } }
Get Answers For Free
Most questions answered within 1 hours.