Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »

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:
• Parallel a
ays
• Passing a
ays 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 co
ect 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 a
ays you need for this assignment:
names: The string a
ay of size 10 that will store students’ names in each of its elements.
co
ectAs: The char a
ay of size 10 that you populate via the input file key.txt.
studentAs: The char a
ay 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 a
ay 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 a
ay in the sense that the grade stored in
index 0 of a
ay grades belongs to the name stored in index 0 of a
ay names.
statA
ay: This a
ay will be used to work as a tally a
ay keeping track of number of co
ect
answers per question on this test. As you can see there are exactly 10 questions on this test. Each
cell in the statA
ay 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 a
ay will indicate the number of co
ect answers given for question #1,
etc.
The functions that you will need for this assignment:
whatGrade: This function receives co
ectAs a
ay, studentAs a
ay 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 co
ectAs, studentAs, statA
ay a
ay and their
size, it keeps the count of the student’s co
ect answers and update the statA
ay. The stat for
question 1 goes to index 0 of the statA
ay. As you can see this function receives the
statA
ay, and modifies it. We know that functions that alter the a
ays 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 a
ay as well as names a
ay 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 co
ectAs a
ay 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 a
ay,
Set up an inner loop and read the 10 char answers that follow the first name, into
the a
ay studentAs.
Back to the outer loop, call the whatGrade function and pass the co
ectAs and
studentAs a
ays to it. This function will return an integer representing the grade for
that student, store that grade in your grades a
ay in the proper index.
Also call the statCollect function and pass co
ectAs, studentAs, and
statA
ay to it. Let it modify the statA
ay based on the count of the co
ect
answers given by the student per question.
Loop back again: read a new name, and reuse your studentAs a
ay, 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 co
ectly 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 XXXXXXXXXXSpring 2022

A A C D B B A D C D

Rebecca    A A C D B B A C C D
Joseph    A A B D B A A C C D
Sarah    A A C A B D A C B D
Kevin    A C C B D C A A B D
Bella    A A A D B C D C D D
David    A A B C C D C A B D
Emma    A C D A A A B D C D
Nora    A A B B C A A C C D
Sean    A A C A A B D D A D
Finn    A B A D B B B A A D
Answered Same Day Feb 06, 2022

Solution

Tanisha answered on Feb 06 2022
100 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