Question: How would you make classes for this assignment? This is in C++ btw. Class structure assignment. This is what is asked for- This is what

How would you make classes for this assignment? This is in C++ btw. Class structure assignment.

This is what is asked for- How would you make classes for this assignment? This is in C++

This is what I already have written from a previous assignment we are supposed to go off of.

#include

#include

#include

using std::cout; using std::endl;

using std::cin;

using std:: trunc;

using std:: string;

void quit_grading(int command)

{

if (command == 1)

{

cout

}

else if (command == -1)

{

cout

}

else

{

cout

}

exit(0);

}

double get_grade()

{

string answer;

double grade_enter;

cout

cin>> answer;

//answer = "yes";

if (answer != "yes")

{

quit_grading(1);

}

else

{

cout

cin>> grade_enter;

//check the user is inputting valid grades

if ((grade_enter 100)

{

quit_grading(-1);

}

else

{

return grade_enter;

}

}

}

double get_average (std::array grades)

{

double sum = 0;

double avg = 0;

int n=10;

for (int i = 0; i

{

//cout

sum += grades[i];

}

avg= sum/ n;

//cout

return avg;

}

int main()

{

//initialize variables

int n= 11;

int temp=0;

int pos;

double sum, avg= 0.0;

//arrays that will be used to store data

std::array grades= {};

std::array numbers= {1,2,3,4,5,6,7,8,9,10,11};

/*User instructions + initial loop to allow user to input their grades into array*/

cout

cout

cout

for (int i=0; i

{

cout

grades[i]=get_grade();

}

//find the lowest grade the student received

double min = grades[0];

int min_index = 0;

for (int i =1; i

{

if (grades [i]

{

min=grades [i];

min_index = i;

}

}

grades[min_index]=grades[10];

grades[10]=min;

/*I know this is not how I am supposed to do this part I am sorry I couldn't figure out how to remove a minimum element from an array*/

//cout

// for (int i=0; i

// {

// grades[i]=grades[i+1];

// }

n--;

for (int i=0; i

{

cout

}

avg= get_average(grades);

cout

if (avg >=90)

{

cout

}

else if ((avg >=81) && (avg

{

cout

}

else if ((avg >=71) && (avg

{

cout

}

else if ((avg >=81) && (avg

{

cout

}

else if ((avg >=61) && (avg

{

cout

}

else

{

cout

}

quit_grading(0);

}

We will now refactor our code by adding: 2 classes for student information and grades. No header files are needed: - Move our grade code to a Class should have: a scalar lowest grade an array of all the grades (the 10 not lowest grades) A display all grades function which prints all of these Move other functions and adjust to work in class - Add a class Student which holds: the class variables: - student name - gradelevel - major a constructor function which sets up the defaults as - grade level as "sophomore" - major as "computer science" - a getter and setter function for each variable: - The main program should now instance the Student class and assignments structure get the student's name and set it display the default gradelevel and major (from the class) and ask if this is correct - if its not get new values for them and set it get all the grades as normally and calculate as normally - only now we use the structure to see the lowest grade and check directly against that record

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!