Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java PreferredCustomer Class A retail store has a preferred customer plan where

ID: 3588298 • Letter: J

Question

Java

PreferredCustomer Class
A retail store has a preferred customer plan where customers can 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, as follows:
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 inherits from the Customer class you cre-
ated in Programming Challenge 7. The PreferredCustomer class should have fields for
the amount of the customer’s purchases and the customer’s discount level. Write one or
more constructors and the appropriate mutator and accessor methods for the class’s fields.
Demonstrate the class in a simple program.

Name: Julie James Address: 123 Main Street Telephone: 555-1212 Customer Number 147-A049 Mailing List: YES Purchases: $1,750.00 Discount level: 0.07

Explanation / Answer

003

#include <string>

004

using namespace std;

005

006

#ifndef PERSON

007

#define PERSON

008

009

class PersonData

010

{

011

       protected:

012

                  string lastName;

013

                  string firstName;

014

                  string address;

015

                  string city;

016

                  string state;

017

                  string zip;

018

                  string phone;

019

020

      public:

021

                 void setLastName(string l);

022

                 string getLastName();

023

                 void setFirstName(string f);

024

                 string getFirstName();

025

                 void setAddress(string a);

026

                 string getAddress();

027

                 void setCity(string c);

028

                 string getCity();

029

                 void setState(string s);

030

                 string getState();

031

                 void setZip(string z);

032

                 string getZip();

033

                 void setPhone(string p);

034

                 string getPhone();

035

};

036

#endif

037

038

// personData.cpp

039

040

#include "personData.h"

041

042

void PersonData::setLastName(string l)

043

{

044

    lastName = l;

045

}

046

047

string PersonData::getLastName()

048

{

049

    return lastName;

050

}

051

052

void PersonData::setFirstName(string f)

053

{

054

    firstName = f;

055

}

056

057

string PersonData::getFirstName()

058

{

059

    return firstName;

060

}

061

062

void PersonData::setAddress(string a)

063

{

064

    address = a;

065

}

066

067

string PersonData::getAddress()

068

{

069

    return address;

070

}

071

072

void PersonData::setCity(string c)

073

{

074

    city = c;

075

}

076

077

string PersonData::getCity()

078

{

079

    return city;

080

}

081

082

void PersonData::setState(string s)

083

{

084

    state = s;

085

}

086

087

string PersonData::getState()

088

{

089

    return state;

321

cout << PreferredCustomer.setdiscountLevel << endl

003

#include <string>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote