Question

Write a program in C++ that inputs an unknown number of test scores (assume that there...

  1. Write a program in C++ that inputs an unknown number of test scores (assume that there is a maximum of 150 scores). Ask the user how many scores that they will be entering. The program should have at least 3 functions. Make sure the functions perform the following:
    1. Calculate the average score
    2. Find the highest score
    3. Find the lowest score
    4. Sort the list from highest to lowest

Output the number of scores, the average, the sorted list, the highest, and the lowest. Use the following data to enter: 10

100 90 89 98 50 66 89 80 92 99

Homework Answers

Answer #1

Code Screenshot :

Executable Code:

#include <iostream>
using namespace std;
void average(int arr[],int n){
   double avg ,sum = 0;
   for (int i = 0; i < n; i++)
   {
       sum+=arr[i];
   }
   cout<<"\nAverage: "<<sum/n;
}
void highest(int arr[],int n){
   int max = arr[0];
   for (int i = 0; i < n; i++)
   {
       if (max < arr[i])
           max = arr[i];
   }
   cout<<"\nHighest Marks: "<<max;
}
void lowest(int arr[],int n){
   int i;
   int min = arr[0];
   for (i = 0; i < n; i++)
   {
       if (min > arr[i])
           min = arr[i];
   }
   cout<<"\nLowest Marks: "<<min;
}
void sort(int arr[],int n){
   int i,temp,j;
       for(i=0;i<n;i++)
       {      
           for(j=i+1;j<n;j++)
           {
               if(arr[i]<arr[j])
               {
                   temp =arr[i];
                   arr[i]=arr[j];
                   arr[j]=temp;
               }
           }
       }
       cout<<"\nMarks after sorting :"<<endl;
       for(i=0;i<n;i++)
           cout<<arr[i]<<"\n";
       cout<<endl;
}
int main()
{
   int marks[150],size;
   cout<<"Please enter the number of test scores: ";
   cin>>size;
   for(int i=0 ;i<size; i++){
       cin>>marks[i];
   }
   highest(marks,size);
   lowest(marks,size);
   sort(marks,size);
   average(marks,size);
   return 0;
}

Sample Output :

Please comment below if you have any queries.
Please do give a thumbs up if you liked the answer thanks :)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
The file scores.txt (attached above) contains a list of names and test scores. Create a program...
The file scores.txt (attached above) contains a list of names and test scores. Create a program that reads each line of the file and determines the highest score and who obtained it. This is an exercise in strings. You are required to use at least one string method to determine the names and the scores. Your output should resemble the following: Highest Score: 100 Achieved by: Jay The text file looks like this: Jan 86 Drew 92 Blake 85 Alex...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
Create a program to calculate and print basic stats on a set of a given input...
Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an quiz. 1) Ask the user for the total number of quiz scores to be input (assume a positive integer will be given). 2) Create an array to hold all the quiz scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should...
AM -vs- PM Test Scores: In my PM section of statistics there are 30 students. The...
AM -vs- PM Test Scores: In my PM section of statistics there are 30 students. The scores of Test 1 are given in the table below. The results are ordered lowest to highest to aid in answering the following questions. index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 score 43 48 50 52 55 60 61 62 64 65 66 67 68 71 75 index 16 17 18 19 20 21 22...
Write a java program that creates an integer array with 50 random values, prompts the user...
Write a java program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. “Out of Bounds”) and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs,...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input file has an unknown number of numeric values(could be empty too).Read the numbers from the input fileand store even numbers in one arrayand odd numbers in another array.Create menu options to Display count of even numbers, count of odd numbersand the sum values in each array Determine the average of each array Determine the median of each array Sort each array in ascending order(use...
C++ project The project will allow you to create a system for tracking the games and...
C++ project The project will allow you to create a system for tracking the games and the scores in terms of graphics, story and replay value and will compute the highest score in each category and the highest overall score. The system will allow you to track 5 games in the following arrays: 1) A string array for the game titles 2) An int array for graphics scores from 1 to 5 3) An int array for replay value from...
PLEASE USE LOOPS ONLY TO COMPLETE THIS ASSIGNMENT. (Find the three lowest scores) Write a program...
PLEASE USE LOOPS ONLY TO COMPLETE THIS ASSIGNMENT. (Find the three lowest scores) Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the lowest score and the student with the second-lowest score and the student with the third lowest score. Program must accept first name only or first and last name SAMPLE RUN #1: java ThreeLowestScores   Enter the number of students:6↵ Student 1 of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT