Ask Question
16 November, 07:18

Write a program that requests the user for three decimal test scores between 0 and 100. Your program will then find the average of the two highest scores. You are to use three separate IF statements to determine which score is the smallest. The average is to be formatted to one decimal place.

+4
Answers (1)
  1. 16 November, 08:42
    0
    import java. util. Scanner;

    public class num9 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter three numbers between 0 and 100");

    double num1 = in. nextDouble ();

    double num2 = in. nextDouble ();

    double num3 = in. nextDouble ();

    double min = 0;

    double sMin = 0;

    double tMin = 0;

    if (num1
    min = num1;

    sMin = num2;

    tMin = num3;

    }

    else if (num2
    min = num2;

    sMin = num1;

    tMin = num3;

    }

    else if (num3
    min = num3;

    sMin = num1;

    tMin = num2;

    }

    double average = (sMin+tMin) / 2;

    System. out. printf ("The average of the two highest scores is:%.1f / n", average);

    }

    }

    Explanation:

    Using Java programming language. The Scanner class is used to receive the three numbers. The user is prompted to enter a valid number between 0 and 100. Using three IF statements the minimum (min), second largerst (sMin) and the largest (tMin) of the three numbers is determined. the average of the sMin and tMin is calculated and printed to the console with the printf method to one decimal place.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that requests the user for three decimal test scores between 0 and 100. Your program will then find the average of the two ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers