Why do my teacher want me to use a run function in this program? How would you start?
COSC 1560 Programming II Spring 2016 1
Assignment #7: Test Scores
Due: Wed. March 23rd
For this assignment you will practice using pointer notation to access elements of a one dimensional array.
This program will utilize an array to store students? test scores. Once all the scores have been loaded, the array
will be passed to a function that will sort them in ascending order. The array will then be sent to another
function that will calculate the student?s average score. The program will then display the student?s list of
scores and their average score. You may only use pointer notation when accessing the elements of the array.
First, your program may NOT contain any global variables other than those that are being used to be size
declarators for arrays.
When main begins you will immediately call the run() function.
o This function, which is called by main() is responsible for executing the program. It will first
declare a filestream and open the file, scores.txt.
o Next, you will declare and array of integers names, scores.
o Next, you will read the first line in the file which indicates how many students are represented
in the file (how many arrays of data). This integer value indicates the number of times you will
loop and call the loadData function.
o After the array has been loaded, you will then call the sortArray function to sort the array.
o Once sorted, you will then calculate the average test score. This return value should be stored
in a variable.
o You will then call the outputArray function to output the results for the current student to file.
COSC 1560 Programming II Spring 2016 2
void loadData(int scores, const int SIZE, fstream & inFile);
o This function will receive the array, the size of the array, and an open filestream. You will
continue reading the next 10 elements from file and load them one by one into the array using
void sortArray(int scores, cons tint SIZE);
o This function will receive the array and the size of the array. It will sort the array in ascending
order (a ? z). Use a sort algorithm of your choosing (bubble sort or selection sort). You MUST
use pointer notation within the sort function.
double calcAverage(int scores, const int SIZE);
o This function will receive the array and the size of the array. It will calculate the average for the
array of scores. It will return the average.
void outputScores(int scores, const int SIZE, int num_student, double avg, fstream &outFile);
o This function will receive the loaded array, the size of the array, the student number, the
average for the current student, and a filestream. This function will use a ?for? loop to iterate
through the array and output each object to the text file, a7.txt. You will need to open the file
stream (appending) prior to going into the loop to output. The output to the file will look like
STUDENT TEST SCORES
77 79 82 83 84 87 88 89 90 97
Average Score: 85.6
Please make sure you include the appropriate program header information at the top of the first page of your
program (see the style guide for example). When you are finished, compile, and then run the program. If it
does not compile, fix any errors and try again. When your program is working, print your program file and
upload your .cpp file and you output file to Canvas by Wednesday, March 23rd.
This question was answered on: Oct 07, 2020
Buy this answer for only: $15
This attachment is locked
We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free copy (Deadline assured. Flexible pricing. TurnItIn Report provided)
Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
About this QuestionSTATUS
Oct 07, 2020EXPERT
GET INSTANT HELP/h4>
We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.
You can also use these solutions:
- As a reference for in-depth understanding of the subject.
- As a source of ideas / reasoning for your own research (if properly referenced)
- For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
NEW ASSIGNMENT HELP?
Order New Solution. Quick Turnaround
Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.
WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.