C++ Define a class PersonalRecord, which will be storing an employee’s information. Internally, the class should have the...

80.2K

Verified Solution

Question

Programming

C++

Define a class PersonalRecord, which will bestoring an employee’s information.


Internally, the class should have the following attributes:

SSN (string type), fullName (string type),homeAddress (string type), phoneNumber (stringtype), salaryRate (per year, float type), andvacationDays (accrued vacation, int type).


The constructor should take six parameters:

four of them are necessary to provide values to at the time ofinitialization (when a constructor will be called/invoked):SSN, fullName, homeAddress, andphoneNumber;

and two of them are optional parameters: salaryRate,vacationDays with values by default to be 0 for each.


Provide natural implementation for the member functions:

getName(), setName(name), getSalary(), andsetSalary(salary).


Use the header file (.h) and the source-code file (.cpp) toseparate the interface of the class from its implementation.


You don’t need to incorporate any checks on validity ofdata.


The test code given below creates two records for the followingpeople (if you want to use it for testing, put in into a separate.cpp file):

John Hue; SSN: 111119911; Address: 234 Avenue B, Brooklyn, NY;phone number: (718) 222-3445; salary: $35000.

Mary Jones; SSN: 222334455; Address: 123 Kings Avenue, Apt. 10,Queens, NY; phone

number: (718) 555-3112.

Then calls some of the methods to see that they are working.


Feel free to use a C++ code editor. When putting the answerbelow, first put the content of the header file, followed with

//--------------- implementation

comment, then put the content of the source-code file.

Test code:

#include

#include \"PersonalRecord.h\"
using namespace std;


int main() {

  PersonalRecord p1(\"111119911\", \"John Hue\", \"234Avenue B, Brooklyn, NY\", \"(718)222-3445\", 35000);

  cout << p1.getName() << \" earns $\"<< p1.getSalary() << \" per year\n\";

  PersonalRecord p2(\"222334455\", \"Mary Jones\", \"123Kings Avenue, Apt. 10, Queens, NY\", \"(718)555-3112\");

  cout << p2.getName() << \" earns $\"<< p2.getSalary() << \" per year\n\"; cout << \"after the information is updated: \" << endl;

p2.setName(\"Mary A Jones\");

p2.setSalary(50000);

cout << p2.getName() << \" earns $\" <

}

Answer & Explanation Solved by verified expert
4.5 Ratings (788 Votes)
PersonalRecordhPersonalRecord header fileincludeclass PersonalRecordprivateprivate data membersstdstring SSN fullName homeAddressphoneNumberfloat salaryRateint vacationDayspublicconstructors with four parametersPersonalRecordstdstring SSN stdstring fullNamestdstring homeAddress stdstring phoneNumberconstructors with five parametersPersonalRecordstdstring SSN stdstring fullNamestdstring    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students