Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question
100%

Answer this in C++:

In the Student.cpp file and Student.h file, build the Student class with the following specifications:

  • Private data members
    • string name - Initialized in default constructor to "Louie"
    • double gpa - Initialized in default constructor to 1.0
  • Default constructor
  • Public member functions
    • SetName() - sets the student's name
    • GetName() - returns the student's name
    • SetGPA() - sets the student's GPA
    • GetGPA() - returns the student's GPA

Ex. If a new Student object is created, the default constructor sets name to "Louie" and gpa to 1. The output of GetName() and GetGPA() before and after calling SetName("Felix") and SetGPA(3.7) is:

Louie/1

Felix/3.7

main.cpp

#include <iostream>
#include <vector>
 
#include "Student.h"
using namespace std;
 
int main() {
    Student student = Student();
    cout << student.GetName() << "/" << student.GetGPA() << endl;
 
    student.SetName("Felix");
    student.SetGPA(3.7);
    cout << student.GetName() << "/" << student.GetGPA() << endl;
 
return 0;
}
 
Student.h
 
#ifndef STUDENT_H_
#define STUDENT_H_
 
#include <iostream>
using namespace std;
 
class Student {
 
    public:
       Student();
    void SetName(string n);
    // FIXME: Declare 3 more functions
     
    private:
        // FIXME: Add 2 private data members
};
 
#endif /* STUDENT_H_ */
 
Student.cpp
 
// Simple class to hold student information
#include "Student.h"
 
#include <iostream>
#include <string>
 
using namespace std;
 
Student::Student() {
   //FIXME: complete the constructor
}
 
void Student::SetName(string n) {
//FIXME: complete SetName function
}
 
// FIXME: Add 3 more functions
Expert Solution
Check Mark
Step 1

The answer is given below:-

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY