Reference no: EM13165472
Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to "X" if no arguments are supplied. Also include a display function. Write a main() function that instantiates and displays two Person objects: one that uses the default values, and one for which you supply your own values. Save the file as Person.cpp.
Create a class named SavingsAccount . Provide fields for the customer use the Person class, account number, balance, and interest rate. Provide two constructors. One requires a customer and sets each numeric field to 0; the other requires a customer and an account number and sets the account's opening balance to $100 at 3% interest. Include a function that displays an account's data fields. Write a main() function that instantiates one SavingsAccount object of each type and displays their values. Save the file as SavingsAccount.cpp
So far I have this for Person.cpp
#include
#include
using namespace std;
class Person {
private:
string firstName;
string lastName;
string zipCode;
public:
Person();
void setValues();
void displayValues();
};
Person::Person()
{
firstName = "X";
lastName = "X";
zip = "X";
}
void Person::setValues()
{
cout << "Please enter your first name" << endl;
cin >> firstName;
cout << "Please enter your last name" << endl;
cin >> lastName;
cout << "Please enter your Zip code" << endl;
cin >> zipCode;
}
void Person::displayValues()
{
cout << "Your first name is: " << firstName << endl;
cout << "Your last name is: " << lastName << endl;
cout << "Your Zip code is: " << zipCode << endl;
}