Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program named, gradeProcessor.cpp , that will do the following tasks: Print welcome message Generate the number of test scores the user enters;

Write a C++ program named, gradeProcessor.cpp, that will do the following tasks:

Print welcome message

Generate the number of test scores the user enters; have scores fall into a normal distribution for grades

Display all of the generated scores - no more than 10 per line

Calculate and display the average of all scores

Find and display the number of scores above the overall average (previous output)

Find and display the letter grade that corresponds to the average above (overall average)

Calculate an display the average of the scores after dropping lowest score

Find and display the number of scores above the dropped score average

Find and display the letter grade that corresponds to the average above (dropped score average)

Find and display the minimum of all scores

Find and display the maximum of all scores

Display a histogram of all scores in terms of their corresponding letter grades (see examples)

Display the occurrence counts for every score appearing in the list more than once

Print termination message

The example output shows several executions of this program. Make your output look like these examples, although you input and generated values will be different.

There are requirements for these tasks that will now be explained. Some of the requirements also imply certain restrictions you must follow in your design and implementation. There is a specific list of functions that you must implement. The requirements give you their exact names, parameter lists, and return types. You follow these exactly to get full credit for this assignment.

int generateOneScore() This first function is given to you for free!! All you have to do is copy the code below into your own gradeProcessor.cpp file. As the function's prolog states, seed the random number generator in main just after beginning execution of your application, then call this function whenever you need another score to put into the array of scores. You should understand when and where to use this function as you understand more about this program. Here is the code:

///////////////////////////////////////////////////////////////////////////// // This function uses the random number generator to generate a test score // that falls into a somewhat typical distribution for grades. To use this // function, first, randomly seed the generator in your main function once // and then call this function as needed. Seed by calling: srand(time(0)) ///////////////////////////////////////////////////////////////////////////// int generateOneScore() { const int A = 14; // ~14% of scores are A const int B = 39; // ~25% of scores are B const int C = 75; // ~36% of scores are C const int D = 89; // ~14% of scores are D const int F = 100; // ~11% of scores are F const int MIN_A = 90; const int MIN_B = 80; const int MIN_C = 70; const int MIN_D = 60; // generate a number bewteen 1 and 100, inclusive // to determine which letter grade to generate int whichLetter = rand() % 100 + 1; // 1..100 // Set min and max based on the letter grade int min, max; if (whichLetter <= A) { min = MIN_A; max = 101; } else if (whichLetter <= B) { min = MIN_B; max = MIN_A; } else if (whichLetter <= C) { min = MIN_C; max = MIN_B; } else if (whichLetter <= D) { min = MIN_D; max = MIN_C; } else { min = 0; max = MIN_D; } // Generate a random score for the chosen letter grade int score = rand() % (max-min) + min; return score; } 

NOTE: You may want to use the MIN_A, MIN_B, etc. named constants elsewhere in your code, so you should remove them from this function and paste them before your main where named constants are usually declared.

void getNumberOfScores( int& ) One Parameters: type int, passed by reference Description: Prompts the user to enter the number of scores that will be used during this execution of the application USE: Caller invokes this function to get the number of scores to process at the beginning of the application's execution

void generateScores( int list[], int n ) Two Parameters: array of integers and number of integers currently stored in the array Description: This function will write n scores into the array of scores named, list. The scores are generated one at a time by calling generateOneScore. USE: Caller invokes this function to populate the array, list, with n scores

double calcAverage (int list[], int n, bool drop) Three Parameters: array of integer scores, number of scores currently in list, and boolean flag, drop Description: Calculate the average of the first n scores stored n the array. If drop is true, do not include the lowest score in this calculation. If drop is false, include all n scores. When this function needs to drop the lowest score, it should call the function, findLowest (see below). The average should be accurate to fractional values and NOT always be an integer: in other words, watch the expression you use to do the calculation of the average. USE: Caller invokes this function to have computed the average of the first n elements of an array; may do so with or without lowest grade.

int findLowest(int list[], int n) Two parameters: array of integers and an integer holding the number of values currently in the array Description: searches the list to find the smallest (lowest or minimum) value, returns that value USE: This function is called when the caller need to have the lowest value in the array returned.

int findHighest(int list[], int n) Two parameters: array of integers and an integer holding the number of values currently in the array Description: searches the list to find the highest (largest or maximum) value, returns that value USE: This function is called when the caller need to have the highest value in the array returned.

int countAboveAverage (int list[], int n, double average) Three Parameters: array of integers, number of integers stored in the array, and average of values in array Description: count and return the number of values in the array that are above the average. USE: Caller invokes this function to have computed the number of the first n scores of the list that are greater than the average of those n scores. Note: This function does NOT call a function to calculate the average. The caller passes the value of the average in as the third parameter.

void displayScores(int list[], int n) Two Parameters: array of integers and number of integers stored in the array Description: print the n scores found in the array, list. Print 10 on each line. If n is not divisible by 10, then there should be fewer than 10 scores on the last line only. See example output. USE: Caller invokes this function to display the contents of the array of scores

char findLetterGrade(double grade) One Parameter: value of type, double Description: determine the letter grade (type, char) for the numeric score, grade USE: Caller invokes this function to determine the letter grade appropriate for a given numeric score

void displayHistogram( int list[], int n ) Two Parameters: array of integers and number of integers stored in the array Description: Displays a histogram of all scores in terms of the letter grade for each score. The display heading states how many scores ( n ) are in the histogram, then displays one star for each score that is an A on line one of the histogram. On line two there should be one star for each score that is a B. Proceed this way for all five letter grades (A, B, C, D, F). Each line should begin with a label containing the letter grade for that line. See several examples in the example output. Make sure your output is exactly the same. USE: Invoked by main to display the histogram of all scores

void displayDuplicateScores( int list[], int n ) Two Parameters: array of integers and number of integers stored in the array Description: For all scores appearing in the list more than one time, this function displays those scores and their occurrence counts. See several examples in the example output. USE: Invoked by main to display the occurrence counts for scores appearing in the list more than one time

function: main Your main function should control the execution of each of the tasks in the list at the top of this page. Use the example output as a guide to help developing main so that this application works as required and looks like the examples in the example output. Notice: while the array of scores is always declared to have 100 elements, the number of elements actually used during an execution is the number entered by the user (2..100). This is why the user's input value (n) is passed around to the various functions: so these functions know how many elements of the array to use. The unused elements should be ignored.

Coding Requirements and Restrictions

All variables must be declared locally to a function. No global variables.

Make sure your program has good prompts and clearly labeled output. Add blank lines to the output to improve its readability. OR: Make your output look exactly like the examples.

Do NOT use any language constructs that have not been covered in class.

Make your code readable by using meaningful variable names, indentation and spacing in other words, ALL of the coding conventions for this course.

All functions must be documented with a description just before the function's header line.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory Icdt 99 7th International Conference Jerusalem Israel January 10 12 1999 Proceedings Lncs 1540

Authors: Catriel Beeri ,Peter Buneman

1st Edition

3540654526, 978-3540654520

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago