Ask Question
22 October, 19:12

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.

+2
Answers (1)
  1. 22 October, 22:51
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers