SP22_1137_Lab2 COSC1137 - Fundamentals of Programming Lab II XXXXXXXXXXSpring 2022 Lab Programming Assignment 1 Due Date: Sunday, Feb 6th 11:59 pm This lab addresses the following major topics: •...

1 answer below »
How would a code this in C++?


SP22_1137_Lab2 COSC1137 - Fundamentals of Programming Lab II Spring 2022 Lab Programming Assignment 1 Due Date: Sunday, Feb 6th 11:59 pm This lab addresses the following major topics: • Parallel arrays • Passing arrays to functions. You are asked to write a program that helps grading a multiple-choice test. We have two input files for this program: • key.txt: This file contains the correct answers to a 10 multiple-choice questions. An example of this file could be as follows: A A C D B B A D C D • student-answers.txt: This file contains the first names of exactly 10 students followed by their answers. An example segment of this file could be as follows: Rebecca A A C D B B A C C D Joseph A A B D B A A C C C . . . Here are the arrays you need for this assignment: names: The string array of size 10 that will store students’ names in each of its elements. correctAs: The char array of size 10 that you populate via the input file key.txt. studentAs: The char array of size 10 that will be used and reused in storing each individual student’s answers listed in input file student-answers.txt. grades: This integer array of size 10 will be used to store each individual student’s grade in the proper index. It will be used in parallel with the names array in the sense that the grade stored in index 0 of array grades belongs to the name stored in index 0 of array names. statArray: This array will be used to work as a tally array keeping track of number of correct answers per question on this test. As you can see there are exactly 10 questions on this test. Each cell in the statArray could be used to represent the stat regarding each question. Notice you have to find a way to map index 0 to question #1, etc. After successful tallying, the number stored in index 0 of this array will indicate the number of correct answers given for question #1, etc. The functions that you will need for this assignment: whatGrade: This function receives correctAs array, studentAs array and their size, it computes their grade and returns it. The prototype of this function is: int whatGrade(char[], char[], int); statCollect: This function receives correctAs, studentAs, statArray array and their size, it keeps the count of the student’s correct answers and update the statArray. The stat for question 1 goes to index 0 of the statArray. As you can see this function receives the statArray, and modifies it. We know that functions that alter the arrays they receive as parameters modify them permanently; and this is exactly what we want to achieve here. The prototype of this function is: void statCollect(char[], char[], int[], int); topStudentsName: This function receives the grades array as well as names array and their size. Looks for the highest grade, uses its index to look up and return the name associated with that grade/index. This function will be used in menu option 2. The following is its prototype: string topStudentName( int[], string[], int); Here is the to do list of major steps to take to write this program: •Populate the correctAs array by reading the data in key.txt file. •Set up a loop to iterate 10 times to read the contents of student-answers.txt. On each iteration: Read the first name into names array, Set up an inner loop and read the 10 char answers that follow the first name, into the array studentAs. Back to the outer loop, call the whatGrade function and pass the correctAs and studentAs arrays to it. This function will return an integer representing the grade for that student, store that grade in your grades array in the proper index. Also call the statCollect function and pass correctAs, studentAs, and statArray to it. Let it modify the statArray based on the count of the correct answers given by the student per question. Loop back again: read a new name, and reuse your studentAs array, and repeat the above steps until you finish reading data from the file. Now you are ready to display the following menu, and let the user use the data you have collected and processed: 1. Look up a student’s grade Please enter the first name. 2. What is the name of the student with the highest grade? 3. How many questions were answered correctly by ALL students? 4. Exit • Make sure you submit a program that compiles. An incomplete program that compiles could possibly earn partial points, a non-compiling program will be considered void. • Attend the online lab assistance sessions to seek help when needed. Send a message to the lab assistant to make an appointment. • Submit your .cpp file on blackboard by the due date. • This is an individual work, a partially or fully identical submissions will earn a grade of zero for all involved. COSC1137 - Fundamentals of Programming Lab II Spring 2022 A A C D B B A D C D RebeccaA A C D B B A C C D JosephA A B D B A A C C D SarahA A C A B D A C B D KevinA C C B D C A A B D BellaA A A D B C D C D D DavidA A B C C D C A B D EmmaA C D A A A B D C D NoraA A B B C A A C C D SeanA A C A A B D D A D FinnA B A D B B B A A D
Answered Same DayFeb 06, 2022

Answer To: SP22_1137_Lab2 COSC1137 - Fundamentals of Programming Lab II XXXXXXXXXXSpring 2022 Lab Programming...

Tanisha answered on Feb 06 2022
112 Votes
Smith John 1525.25
Johnson Olivia 750.25
Bond James 6000.75
Duck Donald 450.75
Mouse Micky 5525.
00
Poor Joe 1000.00
Rich Lawyer 3500.00
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here