Write a program scores.cpp that dynamically allocates an array large enough to hold a user- defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Do not accept negative numbers for test scores.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 6PP: (Numerical) a. Define an array with a maximum of 20 integer values, and fill the array with numbers...
icon
Related questions
Question

Use C++
and please follow the instructions and pro

Write a program scores.cpp that dynamically allocates an array large enough to hold a user-
defined number of test scores. Once all the scores are entered, the array should be passed to a
function that sorts them in ascending order. Another function should be called that calculates the
average score. The program should display the sorted list of scores and averages with appropriate
headings. Use pointer notation rather than array notation whenever possible. Do not accept
negative numbers for test scores.
We will need to write some functions to help us complete this program. The function prototypes
are as follows:
void sortScores (double *scores, int size);
double computeAverage (double *scores, int size);
Sample Output
How many test scores will you enter? -2
The number must be positive.
How many test scores will you enter? 5
Enter test score 1: 85.5
Enter test score 2: -20
Negative scores are not allowed.
Enter test score 2: 99
Enter test score 3: 53.8
Enter test score 4: 78.2
Enter test score 5: 89
The test scores in ascending order, and their average, are:
53.80
78.20
85.50
89.00
99.00
The average score:
81.10
Notes
• You should format the outputs to two decimal places.
• For sorting, the bubble sort is an easy one, but you can use any other sorting method.
• Make sure to clean up the allocated arrays at the end
program.
• Copy and paste your console outputs after the end of your source file. Remember to comment
the output with /* and */ or multiple //.
• Avoid cryptic variable names and poor indentations.
Transcribed Image Text:Write a program scores.cpp that dynamically allocates an array large enough to hold a user- defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Do not accept negative numbers for test scores. We will need to write some functions to help us complete this program. The function prototypes are as follows: void sortScores (double *scores, int size); double computeAverage (double *scores, int size); Sample Output How many test scores will you enter? -2 The number must be positive. How many test scores will you enter? 5 Enter test score 1: 85.5 Enter test score 2: -20 Negative scores are not allowed. Enter test score 2: 99 Enter test score 3: 53.8 Enter test score 4: 78.2 Enter test score 5: 89 The test scores in ascending order, and their average, are: 53.80 78.20 85.50 89.00 99.00 The average score: 81.10 Notes • You should format the outputs to two decimal places. • For sorting, the bubble sort is an easy one, but you can use any other sorting method. • Make sure to clean up the allocated arrays at the end program. • Copy and paste your console outputs after the end of your source file. Remember to comment the output with /* and */ or multiple //. • Avoid cryptic variable names and poor indentations.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,