Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use this as base please: Learning Objectives: reading data from an input file use of structures and arrays to aggregate data use of functions including

image text in transcribed

use this as base please:

image text in transcribed

Learning Objectives: reading data from an input file use of structures and arrays to aggregate data use of functions including arrays as arguments General Description: Write a program that reads data from a file on students and their project scores. A student consists of the following fields: first name (no spaces) last name (no spaces) average (may have digits past the decimal point) a Partial Array of scores (ints), max 5 the number of scores Input file format: the first line: contains the number of students followed by the number of scores for each student each additional line contains, for each student: first name, last name, a list of scores o Sample input file for 5 students each with 4 scores: 54 Sally Smith 88 77 99 66 Adam Ant 85 75 95 65 Betty Boop 96 94 92 90 Freddy Krueger 66 77 55 44 Pepe LePew 87 77 67 57 Write the following functions: read() - modifies: a partial array of students Opens a file called "students.txt" which has the format described above. Note there may be more or less than 5 students, and more or less than 4 scores per student. When the file fails to open, prints "Unable to open input file", sets the number of scores in the partial array to 0, and exits. Otherwise, the function continues. For each student, reads the first and last names (no spaces) into the partial array of students. for each score, reads the scores into the partial array of scores for the student. When reading is complete, the file is closed. calcAverages(): given a Partial Array of Students For each student, adds up the scores and divides by the number of scores to set the average. print(): given a Partial Array of Students First Last Avg Si S2 S3 S4 S5 Sally Adam Prints a header as shown in the example. Prints the data for each student on one line, with the following field widths: first name 15 last name 15 6 scores 3 Betty Freddy Pepe Smith Ant Boop Krueger LePew 82.50 88 77 99 66 80.00 85 75 95 65 93.00 96 94 92 90 60.50 66 77 55 44 72.00 87 77 67 57 average search(): given a Partial Array of Students, a search First Name and a search Last Name. Searches the partial array for a student with a first and last name that matches the given search names. When found, returns the index in the array where found. When not found, returns - 1. main(): The main() is given on the course web site. Use this to test your functions. Sample Execution: First Last Avg S1 S2 S3 S4 S5 sally Smith 82.50 88 77 99 66 Adam Ant 80.00 85 75 95 65 Betty Boop 93.00 96 94 92 90 Freddy Krueger 60.50 66 77 55 44 Pepe LePew 72.00 87 77 67 57 Enter First and Last to search (or 00): Adam Ant Average is 80.00 Enter First and Last to search (or o ): Pepe LePew Average is 72.00 Enter First and Last to search (or 0 0): Bugs Bunny Not found Enter First and Last to search (or @ 0:00 int main() { student s[MAX_STUDENTS]; int numStu; string sFirst, sLast; read(s, numStu); calcAverages(s, numStu); print(s, numStu); cout > SFirst >> SLast; while (sFirst != "0") { int ndx = search(s, numStu, sFirst, slast); if (ndx == -1) cout > SFirst >> SLast; } return 0

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

6. Are my sources reliable?

Answered: 1 week ago

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago