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

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question

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
Transcribed Image Text: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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,