Question: a) Define a class named Student. It must have the following private member variables i) A long integer to store ID ii) A string to

a) Define a class named Student. It must have the following private member variables

i) A long integer to store ID

ii) A string to store name

iii) A double to store GPA Write a constructor function that allows initializing while creating an object

b) In addition to the constructor functions

i) Add an accessor function of void return type to access the value of all three private member variables. Your accessor function will display the value of the variables inside function.

ii) Add a mutator function of void return type to set/change the value of all three private member variables. Your mutator function will prompt the user for the value of the member variables.

c) Create two objects in your main functionone with values for the initializing/parametrized constructor function, and one without. Use your name, student ID and GPA value of 4.0 to initialize the object using the initializing constructor. Demonstrate the use of accessor function for the first object, and both accessor and mutator functions for the second object.

Here is my code so far. How can I change this to meet the criteria above? I need to make the 3 get functions be 1 void function that prompts the user to enter in values for each variable.

#include  #include  using namespace std; class Student { public: Student(); Student(int id, string name, double gpa); void setvars(int id, string name, double gpa); int getId(); string getName(); double getGpa(); private: int id; string name; double gpa; }; Student::Student() { } Student::Student(int id, string name, double gpa) { } void Student::setvars(int id, string name, double gpa) { this->id=id; this->name=name; this->gpa=gpa; } int Student::getId() { return this->id; } string Student::getName() { return this->name; } double Student::getGpa() { return this->gpa; } int main() { Student student1(12345678, "First Last", 4.0); Student student2; student2.setvars(12345678, "First Last", 4.0); cout << "Student ID: " << student2.getId() << endl; cout << "Student Name: " << student2.getName() << endl; cout << "Student GPA: " << student2.getGpa() << endl; return 0; } 

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!