Create a class
First programming homework
Create a class of records for a gradebook called Rec.
The data should be private, and should include a firstname, lastname, array of three grades, and a field for average grade.
Build two constructors: a default constructor and a constructor that takes the first and last name.
Build a function to read the data, either from a file or from cin. The read function reads the two names and three grades, but does not read the average grade.
Build a write function that writes the data either to a file or to cout. The write function prints all of the data on one line with spaces between fields.
Build a function to calculate the average grade field.
Build an overloaded operator == to compare two records. This should be implemented as a friend function.
Declare the constructors and functions in the body of the class, but implement them outside the class.
I will provide you with a driver called hw1.cpp in ~cthorpe/public/142 and with a test file HW1.txt in the same directory
HW1.txt contains:
Pete Jones 1 2 4
I attached hw1.cpp
![C. OpenSSH SSH client
File Edit Options Buffers Tools C++ Help
#include <iostream>
#include <fstream>
using namespace std;
// Class declaration goes here
// function bodies go here
int main ()
{
Rec r1;
Rec r2("Smith", "Jean");
ifstream instr;
instr.open ("HW1.txt");
cout <« "Blank record" << endl;
r1.write(cout);
cout << "Initialized record" << endl:
r2.write(cout);
r1.read(instr);
if (r1 == r2) cout << "same"; else cout << "different":
cout << endl;
r1.calc_avg();
r1.write(cout);
cout <« endl;
return 0;
All L1
-UU-:%%-- F1 hw1.cpp
Loading cc-langs...done
(C++/1 Abbrev) -----](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa4aac48a-4d20-41e4-aba5-4ec9a336b2fd%2Fba11339d-13a2-4a9f-882a-0c81a86076e9%2Fei9drqq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)