Question

In: Computer Science

Write a program that prompts the user to enter five test scores and then print the...

Write a program that prompts the user to enter five test scores and then print the average test score to the screen. (Assume that the test scores are decimal numbers). Use the following 5 numbers:     10.5      5.5        20.0      10.0      5.5.

I am having trouble understanding where the 5 values are entered in the program.

The program has been provided:

#include <iostream>
    #include <iomanip>
   
    using namespace std;
    
    int main()
    {
        double testScore1;
        double testScore2;
        double testScore3;
        double testScore4;
        double testScore5;
   
        cout << "Enter test score 1: ";
        cin >> testScore1;
        cout << endl;
   
        cout << "Enter test score 2: ";
        cin >> testScore2;
        cout << endl;
       
        cout << "Enter test score 3: ";
        cin >> testScore3;
        cout << endl;
       
        cout << "Enter test score 4: ";
        cin >> testScore4;
        cout << endl;
       
        cout << "Enter test score 5: ";
        cin >> testScore5;
        cout << endl;
       
        cout << "Average test score: " << (testScore1+testScore2+testScore3+testScore4+testScore5)/5 << endl;
        cout << endl;
   

        // when using Visual Studio, use the system/pause command to display the results of your program
        // system("pause");


        return 0;
    }

Solutions

Expert Solution

Program :

#include <iostream>
#include <iomanip>

using namespace std;
  
int main()
{
double testScore1; // Variable declaration for first score
double testScore2; // Variable declaration for second score
double testScore3; // Variable declaration for third score
double testScore4; // Variable declaration for fourth score
double testScore5; // Variable declaration for fifth score
cout << "Enter test score 1: ";
cin >> testScore1; // Accept the first score
cout << endl;

cout << "Enter test score 2: ";
cin >> testScore2; // Accept the second score
cout << endl;

cout << "Enter test score 3: ";
cin >> testScore3; // Accept the third score
cout << endl;

cout << "Enter test score 4: ";
cin >> testScore4; // Accept the fourth score
cout << endl;

cout << "Enter test score 5: ";
cin >> testScore5; // Accept the fifth score
cout << endl;

cout << "Average test score: " << (testScore1+testScore2+testScore3+testScore4+testScore5)/5 << endl; // Find the average of score and print the score
cout << endl;
return 0;
}

Output :


Related Solutions

USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score. Hint: Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument...
Write a program that asks the user to enter five test scores. The program should display...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a test program that prompts the user to enter a sequence of numbers ending with...
Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes this method to return the largest number in the input. Use inheritance and polymorphism approach. in java please
JAVA Write a test program that prompts the user to enter a series of integers and...
JAVA Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program’s main() must prompt the user to enter the input size - i.e., the number of values in the series, the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test...
JAVA Write a test program that prompts the user to enter a list and displays whether...
JAVA Write a test program that prompts the user to enter a list and displays whether the list is sorted or not. Here is a sample run. Note that the program first prompts the user to enter the size of the list. Using Array My output should look like this Enter the size of the list: 8 Enter the contents of the list: 10 1 5 16 61 9 11 1 The list has 8 integers 10 1 5 16...
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Part 1 Write a program that prompts the user to enter three sets of five double...
Part 1 Write a program that prompts the user to enter three sets of five double numbers each. These numbers represent the five grades that each of three students has received. After prompting for the grades, the program: stores the data in a previously defined 3◊5 double array computes the average of each set of 5 grades after acquiring the grades for that one student determines the maximum and minimum values of each set of 5 grades acquiring the grades...
Write a C program that prompts the user to enter three sets of five double numbers...
Write a C program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.) The program should accomplish all of the following: a. Store the information in a 3×5 array. b. Compute the average of each set of five values. c. Compute the average of all the values. d. Determine the largest value of the 15 values. e. Report the results. Each major task should...
Write a program that prompts the user to enter three sets of five double numbers each....
Write a program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.) The program should accomplish all of the following: a. Store the information in a 3×5 array. b. Compute the average of each set of five values. c. Compute the average of all the values. d. Determine the largest value of the 15 values. e. Report the results. Each major task should be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT