For this project we are working on pointers and struts. In particular a struct t
ID: 3690883 • Letter: F
Question
For this project we are working on pointers and struts. In particular a struct that
contains a pointer to a dynamically allocated array. We will be reading in data
related to a fictitious student and their grades. The fact that the weighting and
categories completely align with our course are of course completely on
purpose. You could use this to compute your average in our class.
Details
The main focus in this project is the struct. The struct will be a Student and it
will contain all the fields needed to store grades for that student. It will need the
following fields:
First name
Last name
Their project grades, in a dynamically allocated array
The number of projects
The total point value for the projects, to be used in their average
Their labs grades, in a dynamically allocated array
The number of labs
The total points for their labs, to be used in their average
Their attendance grades, in a dynamically allocated array
The number of attendance grades
The total of their attendance points, to be used in their average
The midterm grade
The midterm total point value
The final exam
The final exam total point value
Optionally, you may also store the following two fields
Their overall average
Their letter grade based on their average
For computing the final average, you sum the number of points the student
earned and you sum the total number of points for the category. Then you divide
the number of points they earned by the number of points they could have
earned and multiply it by the weight for the category. You repeat this for the 3
categories that have more than 1 grade, i.e. projects, labs and attendance. The
midterm and final only have 1 grade and so summing them is not needed. Then
you add the individual parts together and that is the average. The letter grade
uses the following scale:
A: 93-100
A-: 90 < 93
B+: 87 < 90
B: 83 < 87
B-: 80 < 83
C+: 77 < 80
C: 73 < 77
C-: 70 < 73
D+: 67 < 70
D: 63 < 67
D-: 60 < 63
F: < 60
Input
The input will be in the following form. Each line will start with a “tag”. The tag
is one of the following:
First
Last
Attendance
Lab
Project
Midterm
Final
The first and last will be followed by the student’s first and last name
respectively. The rest of the tags will be followed by two numbers. The first
number represents the grade the student scored on the assignment and the
second number represents the total points for the assignment. The tags can
come in any order. See the example below and in the zip file.
Output
The output will be in the format below
First:
Last:
Attendances:
Attendance Grade:
Labs:
Lab Grade:
Projects:
Project Grade:
Midterm:
Midterm Grade:
Final:
Final Grade:
Overall Average:
Letter Grade:
Each of the tags in the output will be followed by the data from the input file.
The list of grades for attendance, labs and projects will be sorted from smallest
to largest. See the selection sort code below. The “Grade” part of the output is
the weighted average for that category.
Weights
We will be using the weights from our syllabus:
Attendance 5%
Labs 15%
Projects 40%
Midterm 20%
Final 20%
Example Input
First: Anna
Last: ALLEN
Project: 83 98
Project: 79 94
Project: 81 92
Midterm: 90 129
Project: 81 92
Project: 94 95
Attendance: 1 2
Lab: 76 95
Attendance: 1 2
Final: 83 123
Attendance: 0 2
Attendance: 0 2
Attendance: 0 1
Lab: 92 91
Attendance: 1 2
Attendance: 1 1
Lab: 87 91
Lab: 91 90
Attendance: 0 1
Lab: 99 96
Lab: 83 91
Lab: 88 97
Lab: 94 96
Attendance: 0 1
Lab: 90 94
Attendance: 0 2
Attendance: 1 1
Lab: 83 93
Attendance: 0 1
Attendance: 1 1
Attendance: 1 2
Attendance: 0 1
Example Output
First: Anna
Last: ALLEN
Attendances: 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
Attendance Grade: 1.59091
Labs: 76 83 83 87 88 90 91 92 94 99
Lab Grade: 14.1809
Projects: 79 81 81 83 94
Project Grade: 35.4989
Midterm: 90
Midterm Grade: 13.9535
Final: 83
Final Grade: 13.4959
Overall Average: 78.7202
Letter Grade: C+
Requirements
To receive full credit from the graders make sure to follow the requirements
below
You must use the header file computeGrades.h
The function void computeGrades( string input, string output );
You must use a dynamically allocated array for the labs, attendance and
projects.
The starting size of those arrays is 5 and you should double when you grow.
You may not use any of the storage components from the STL, e.g. vector,
list, etc.
You must follow the Code style Guide lines as detailed in Canvas.
Global variables are not allowed.
You must write functions for all major parts of the code, e.g. reading the
data, displaying the data, computing the average, etc.
If you have trouble with the dynamic allocation of the array, you may use static
arrays for a 20 point deduction.
Grading
If you receive the message about Unable to locate behavioral analysis, you must
fix that. That means my testing code cannot link with your code.Make sure
you’ve used the correct filename for the .h file and that the function is
prototyped in the header file. Spelling and capitalization count.
Due
Code
Here’s a sort function you can use. I’ll give you one for sorting ints and one for
sorting doubles.
void sortDouble( double storage[], int count )
{
int smallest;
for ( int i=0;i {
smallest = i;
for ( int j=i+1;j {
if ( storage[j] < storage[smallest] )
smallest = j;
}
double temp = storage[smallest];
storage[smallest] = storage[i];
storage[i] = temp;
}
}
void sortInt( int storage[], int count )
{
int smallest;
for ( int i=0;i {
smallest = i;
for ( int j=i+1;j {
if ( storage[j] < storage[smallest] )
smallest = j;
}
int temp = storage[smallest];
storage[smallest] = storage[i];
storage[i] = temp;
}
}
Some other ideas of useful functions would be the following:
A function that takes an array of ints and returns the sum.
A function that takes an array of doubles and returns the sum.
A function that can “grow” an array of doubles.
A function that can “grow” an array of ints.
Explanation / Answer
void sortDouble( double storage[], int count )
{
int smallest;
for ( int i=0;i {
smallest = i;
for ( int j=i+1;j {
if ( storage[j] < storage[smallest] )
smallest = j;
}
double temp = storage[smallest];
storage[smallest] = storage[i];
storage[i] = temp;
}
}
void sortInt( int storage[], int count )
{
int smallest;
for ( int i=0;i {
smallest = i;
for ( int j=i+1;j {
if ( storage[j] < storage[smallest] )
smallest = j;
}
int temp = storage[smallest];
storage[smallest] = storage[i];
storage[i] = temp;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.