Question

This is a C++ program Instructions Design a class named PersonData with the following member variables...

This is a C++ program

Instructions

Design a class named PersonData with the following member variables declared as strings:

  • lastName
  • firstName
  • address
  • city
  • state
  • zip
  • phone

Create 3 constructors; a default constructor, a constructor that accepts the first and last name member variables, and a constructor that accepts all member variables. Write the appropriate accessor/getter and mutator/setter functions for these member variables. Create a method within this class called getFullName() that returns the person's first and last names as a single string.

Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables:

  • customerNumber
  • mailingList

The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool. It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mailing list. There should be a default constructor, a constructor that accepts first and last name along with the member variables of the CustomerData class, and a constructor that accepts all of the member variables in both classes. Write appropriate accessor and mutator functions for these member variables.

A retail store has a preferred customer plan where customers may earn discounts on all their purchases. The amount of a customer’s discount is determined by the amount of the customer’s cumulative purchases in the store

  • When a preferred customer spends $500, he or she gets a 5% discount on all future purchases.
  • When a preferred customer spends $1,000, he or she gets a 6% discount on all future purchases.
  • When a preferred customer spends $1,500, he or she gets a 7% discount on all future purchases.
  • When a preferred customer spends $2,000 or more, he or she gets a 10% discount on all future purchases.

Design a class named PreferredCustomer, which is derived from the CustomerData class you just created. The PreferredCustomer class should have the following member variables:

  • purchasesAmount (a double)
  • discountLevel (a double)

The purchasesAmount variable holds the total of a customer’s purchases to date. The discountLevel member variable should be set to the correct discount percentage, according to the store’s preferred customer plan. Therefore, there should not be a standard setter for this member variable. Instead, write a member function/method called calculateDiscount() that when called, will receive the new sale and evaluate the purchasesAmount member variable with that sale to set the discount level. This method should also return the calculated discount. There should also be an addSale() method that receives a sale amount and accumulates/adds it the the purchasesAmount member variable. Write appropriate member functions and constructors for this class. (Remember to reference to two overloaded constructors written in the parent class. These constructors should not receive the purchases and discount level as parameters as they will be set from other functionalities.)

Input Validation: Do not accept negative values for any sales figures.

Create Driver Program

Create a program called Customer Sales Entry that contains the following requirements:

  • The program should begin by obtaining all of the basic information about the customer, which includes the name, full address, phone, customer number, and whether the customer wants to be on the mailing address. Remember that this program will be used by a sales associate.
  • Customer Number Functionality - The customer number should be generated by the application, not by user entry. To do so, create a text file called CustomerNumber.txt. In this file, simply store the number 1000 that represents a starting customer number. Read the customer number from the file and use as the customer number. Afterwards, increment the customer number and store that number back to the text file so that the next time you run the application, it will have the next customer number ready.
  • Once all of the customer information is obtained, a preferred customer object should be instantiated.
  • The user should then be asked whether they would like to enter in a sale for the customer. If not, notify the user that the program is ending and end the program. If so, obtain that amount of the first sales and set the appropriate purchasesAmount and discountLevel member variables.
  • After the initial sale is entered, the user should be ask if they would like to enter another sale and continue this process until the user has completed entering all sales. Remember to update the purchasesAmount and discountLevel if necessary.
  • Be sure to display the customer name, full address, phone number, the customer number, original sale amount, the total purchases to date, the discount percentage, and the discounted sale amount (if applicable) after each transaction. The should be accomplished with a function called displayCustomerSale() in your main file that receives the PreferredCustomer object via a pointer. (Be sure to use the getFullName() method from the PersonData base class to display name and format all of your currency data with dollar signs and two decimal places.)
  • After all sales have been entered and the sales person is ready to exit the program, check to see if the user is on the mailing list. If not, the program should prompt the user to ask the customer if they would like to be on the mailing list. This message should only appear if the customer is NOT on the mailing list.

Sample Output – (Bold/Red is user input. Also, your output (excluding customer data) must match the output below.)

Customer Sales Entry

--------------------------

Customer first and last name: John Doe

Street Address: 123 Main Street

City: Aur

State: CO

Zip: 00000

Phone: 303-555-0000

Would the customer like to be on our mailing list (Y or N): n

Type 1 to enter sale or 2 to exit: 1

Enter amount of sale: 276.25

Customer Sales Information

----------------------------------

Customer Number: 1000

John Doe

123 Main Street

Aur, CO 00000

Phone: 303-766-0000

Original Sale Amount: $276.25

Customer Discount: 0.00%

Discounted Sale: $276.25

Total Purchases: $276.25

Type 1 to enter sale or 2 to exit: 1

Enter amount of sale: 525.46

Customer Sales Information

----------------------------------

Customer Number: 1000

John Doe

123 Main Street

Aur, CO 00000

Phone: 303-766-0000

Original Sale Amount: $525.46

Customer Discount: 5.00%

Discounted Sale: $499.19

Total Purchases: $801.71

Type 1 to enter sale or 2 to exit: 1

This customer is not on our mailing list!

Would the customer like to be added to our mailing list (Y or N): y

Customer has been added to our mailing list.

The program will now exit!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note : I have some doubt regarding the main() function. Do i need to read any input from the input file...?

___________________________

#include <iostream>

#include <iomanip>

using namespace std;

class Person

{

private :

string lastname;

string firstname;

string address;

string city;

string state;

string zip;

string phone;

public :

Person( string lastname,

string firstname,

string address,

string city,

string state,

string zip,string phone)

{

this->lastname=lastname;

this->firstname=firstname;

this->address=address;

this->city=city;

this->state=state;

this->zip=zip;

this->phone=phone;

}

  

};

class Customer:public Person

{

private :

int customerNumber;

bool mailingList;

string comments;

public :

Customer()

{

this->customerNumber=0;

this->mailingList=false;

this->comments="XXXXXXXX";

}

Customer(string lastname,

string firstname,

string address,

string city,

string state,

string zip,string phone,int customerNumber,

bool mailingList,

string comments):Person(lastname,firstname,address,city,state,zip,phone)

{

this->customerNumber=comments;

this->mailingList=mailingList;

this->comments=comments;

}

}};

class PreferredCustomer:public Customer

{

private :

double purchases;

int discountLevel;

public :

PreferredCustomer(string lastname,

string firstname,

string address,

string city,

string state,

string zip,string phone,int customerNumber,

bool mailingList,

string comments,double purchases):Customer(lastname,

firstname,

address,

city,

state,

zip,phone,customerNumber,

mailingList,

comments)

{

this->purchases=purchases;

if(purchases>500)

this->discountLevel=5;

else if(purchases>1000)

this->discountLevel=6;

else if(purchases>1500)

this->discountLevel=7;

else if(purchases>2000)

this->discountLevel=10;

}

PreferredCustomer()

{

this->purchases=0;

this->discountLevel=0;

}

};

int main()

{

PreferredCustomer pc1()

return 0;

}

______________________________

Add a comment
Know the answer?
Add Answer to:
This is a C++ program Instructions Design a class named PersonData with the following member variables...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName...

    7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailinglist The customer Number variable will be used to hold a unique integer for each customer. The mailing List variable should be a bool....

  • 7. PersonData and CustomerData classes Design a class  named PersonData with the following member variables...

    7. PersonData and CustomerData classes Design a class  named PersonData with the following member variables : lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables . Next, design a class  named CustomerData, which is derived from the PersonData class . The CustomerData class should have the following member variables : customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool....

  • Design a class for python named PersonData with the following member variables: lastName firstName address city...

    Design a class for python named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool . It will be...

  • This must be written in C# with overloaded constructors and member initialization list 4. Person and...

    This must be written in C# with overloaded constructors and member initialization list 4. Person and Customer Classes Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether the customer wishes to be on a mailing list. Demonstrate an object of the Customer class...

  • this is java m. please use netbeans if you can. 7. Person and Customer Classes Design...

    this is java m. please use netbeans if you can. 7. Person and Customer Classes Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the cus- tomer wishes to...

  • Please use Java Question 3: Person and Customer classes: Design a class named Person with properties...

    Please use Java Question 3: Person and Customer classes: Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether wishes to be on a mailing list. Demonstrate an object of customer class in a simple GUI application. Write the code include appropriate input validation,...

  • Assignment 6 Due: Apr 12, 2019 at 11:59 PM A6 OOP 3 "PreferredCustomer Class" (need to...

    Assignment 6 Due: Apr 12, 2019 at 11:59 PM A6 OOP 3 "PreferredCustomer Class" (need to create Person, Customer classes described in the previous problem) Access A6 from pdf assignment file. Turn in the following files: a6main.java Customer.java Person.java PreferredCustomer.java program compile and run screenshots design document (including UML) A6 7. Person and Customer Classes esign a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT