Question: Using C++ Programming. Chapter 9: Using pointer notation and array notation Dynamic Memory Allocation 1.) In main, ask the user how many test scores they
Using C++ Programming.
Chapter 9: Using pointer notation and array notation
Dynamic Memory Allocation
1.) In main, ask the user how many test scores they will be entering. (Input 5 when running the program). Validate input for positive input.
2.) In main, dynamically allocate an array large enough to hold a user-defined number
of test scores.
3.) In main, fill an array with the scores that the user inputs. Validate input for the range of 0 to 100.
Test Data: 80.6 -5 94.5 65.4 100 111 100
4.) Once all the scores are entered into the array, the array should be passed to a function that
calculates the average test score. Here is the function header:
double average(double* score, int numScores)
{
//code to calculate and return average..use pointer notation
}
5.) In main, display the average test score with one number to the right of the decimal point.
6.) Then the array should be passed to a function that calculates how many people got an A on the test. An A is a test score that is > = 90. Here is the function header:
int howManyA(double* score, int numScores)
{
//code to calculate and return the number of A gradesuse array notation
}
7.) In main, display the number of A grades.
8.) Release the dynamically allocated memory at the end of the program.
Remember that when totaling a series of numbers, total must be initialized to 0.
Be sure to format the code and output. Document functions and where appropriate, use phrases when outputting results.
Lab 5 Rubric (40 points)
Document functions (1)
Global prototypes (1)
Local variables (1)
Error trap for positive number of test scores (1)
Dynamically allocate array (5)
Fill the array (2)
using sample test data (-1)
Error trap for correct range of grades (1)
Correct average function call (2)
Initialize total to 0 (1)
Correct average calculation (3)
Use of pointer notation (7)
Display average in main (2)
with 1 number to the right of
the decimal point
Correct call to howmany (2)
Initialize total to 0 (1)
Correct calculation of howmany (1)
Use of array notation (6)
Display howmany in main (2)
Release dynamically allocated memory (1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
