Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trying to figure out how to round the GPA for the students. Everything else works, just need help with the rounding. Note: I put the

Trying to figure out how to round the GPA for the students. Everything else works, just need help with the rounding.

Note: I put the areas I need help with in bold within my ouput and expected output.

Input:

add

Robert

2.8165

add

Nancy

3.76

print

drop

1

print

quit

My output:

Enter Option : Student name: Robert's GPA:

Enter Option : Student name: Nancy's GPA:

Enter Option : 0: Robert has a GPA of 2.8165 1: Nancy has a GPA of 3.76

Enter Option : Index of student to drop:

Enter Option : 0: Robert has a GPA of 2.8165

Enter Option :

Expected output:

Enter Option: Student name: Robert's GPA:

Enter Option: Student name: Nancy's GPA:

Enter Option: 0: Robert has a GPA of 2.8 1: Nancy has a GPA of 3.8

Enter Option: Index of student to drop:

Enter Option: 0: Robert has a GPA of 2.8

Enter Option:

My Code:

#include #include #include #include #include using namespace std; class Student { public: Student(string name = "not intialized", double GPA = 0.0); void SetName(string studentName); void SetGPA(double personName); string ToString() const; private: string name; double GPA; }; Student::Student(string initialName, double initialGPA) { name = initialName; GPA = initialGPA; } void Student::SetName(string inputName) { name = inputName; } void Student::SetGPA(double newGPA) { GPA = newGPA; } //Insert the ToString member function here string Student::ToString() const{ stringstream sstr; sstr << GPA; return name+" has a GPA of "+sstr.str();; } int main() { vector students; //Declare all required variables string option; string name; double GPA; int index; while(true) { cout<<" Enter Option : "; cin>>option; //Check for option add if(option=="add") { //Read student data cout<<"Student name: "; cin>>name; cout<>GPA; //adding student object to vector students.push_back(new Student(name,GPA)); } //Check for option frop else if(option=="drop") { //Read index cout<<"Index of student to drop: "; cin>>index; //Check pre-condition for valid index if(students.size()!=0 && indexToString()<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

There are ____________ digits in the hexadecimal system.

Answered: 1 week ago

Question

3. Who would the members be?

Answered: 1 week ago