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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education