1. Implement a class: a. A Student class with a private nested GPA class and three data members: name, major, b. Use c++11 member initialization to set the default name and major to grade (` is of type GPA) "blank" and GPA to 0.0 for all objects. c. Implement multiple constructors with constructor delegation. d. GPA class: 1) All appropriate accessor and mutator functions. 2) Implement a getLetterGrade function which returns a letter based upon the GPA as such: >=3.5 A, >=2.5 B, >=1.5 C, >=1 D, all else F e. Student class: 1) All appropriate accessor and mutator functions. 2) Apply the const member function modifier as needed. 3) Implement a display member function that prints object data as demonstrated in the output example. Instantiate two objects and display their data as such: Output Example Name: John Williams Major: Music GPA: 4.00 Grade: A Name: Isaac Asimov Major: English GPA: 3.33 Grade: B
I'm stuck on this question and I don't know how I should be approaching this. What should I do?
My code so far:
-----------------
#include <iostream>
using namespace std;
class Student{
public:
Student():grade(0.0){}
void setGrade(double value){
grade = value;
}
void setName(string value){
name = value;
}
void setMajor(string value){
major = value;
}
double getGrade(){
return grade;
}
string getName(){
return name;
}
string getMajor(){
return major;
}
void addStudent(double grade, string value1, string value2){
Student::setGrade(grade);
Student::setName(value1);
Student::setMajor(value2);
}
void display(){
cout<<"Name: "<<Student::getName()<<endl;
cout<<"Major: "<<Student::getMajor()<<endl;
cout<<"GPA: "<<Student::getGrade()<<endl;
cout<<"Grade: ";
}
private:
class GPA{
public:
GPA(){}
void getLetterGrade(double grade) const{
if (grade >= 3.5){
cout<<"A";
}
if (grade >= 2.5 && grade < 3.5){
cout<<"B";
}
if (grade >= 1.5 && grade < 2.5){
cout<<"C";
}
if (grade >=1 && grade < 1.5){
cout<<"D";
}
else cout<<"F";
}
};
string name;
string major;
double grade;
};
int main() {
Student s1;
s1.addStudent(4.0,"John Williams","Music");
s1.display();
cout<<endl;
cout<<endl;
Student s2;
s2.addStudent(3.33,"Isaac Asimov","English");
s2.display();
}
![1. Implement a class:
a. A Student class with a private nested GPA class and three data members:
name, major,
b. Use c++11 member initialization to set the default name and major to
grade (` is of type GPA)
"blank" and GPA to 0.0 for all objects.
c. Implement multiple constructors with constructor delegation.
d. GPA class:
1) All appropriate accessor and mutator functions.
2) Implement a getLetterGrade function which returns a letter based
upon the GPA as such: >=3.5 A, >=2.5 B, >=1.5 C, >=1 D, all else F
e. Student class:
1) All appropriate accessor and mutator functions.
2) Apply the const member function modifier as needed.
3) Implement a display member function that prints object data
as demonstrated in the output example.
Instantiate two objects and display their data as such:
Output Example
Name: John Williams
Major: Music
GPA: 4.00
Grade: A
Name: Isaac Asimov
Major: English
GPA: 3.33
Grade: B](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F613158f8-f57a-4aaf-bb0a-53a23f872da5%2F9a136784-63fe-4b86-a7a4-ca8862744e59%2F7zi89fo.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)