A retail store has a preferred customer plan where customers can earn discounts
ID: 3666657 • Letter: A
Question
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, they get a 5% discount on all
future purchases.
When a preferred customer spends $1,000, they get a 6% discount on all
future purchases.
When a preferred customer spends $1,5000, they get a 7% discount on all
future purchases.
When a preferred customer spends $2,000, they get a 10% discount on all
future purchases.
Design a class named PreferredCustomer, which inherits from the Customer class
you created in Exercise 7. The preferredCustomer class should have int fields
for the amount of the customer's purchases and the customer's discount level.
Write a constructor that initializes these fields as well as accessor and
mutator methods .
Desmonstrate the class in a program that prompts the user to input the
customer's name , address, phone number, customer number, whether they want to
recieve mail, and the amount they've spent, and then uses that information
to create a PreferredCustomer object and print its information. (Use string
formatting to print the amount spent.)
Create all of the classes in the same file by not delcaring any of them public.
Explanation / Answer
public class Person {
private String Name; // The Persons Name
private int phoneNumber; // The Persons Phone Number
private String address; // The Persons Address
public Person()
{
Name="";
phoneNumber = 0;
address = "";
}
public Person (String n, int pn, String ad)
{
Name = n;
phoneNumber = pn;
address = ad;
}
public void setName(String n)
{
Name = n;
}
public void setidnumber(int pn)
{
phoneNumber = pn;
}
public void setdepartmen(String ad)
{
address = ad;
}
public String getName()
{
return Name;
}
public int getphoneNumber()
{
return phoneNumber;
}
public String getaddress()
{
return address;
}
}
======================================...
public class Customer extends Person {
private int customerNumber; // The Customers Number
private String eMail; // The Customers E-Maill
public Customer()
{
}
public Customer (String n, int pn,String ad, int cn, String em)
{
super(n, pn,ad);
customerNumber = cn;
eMail = em;
}
public int getCustomerNumber() {
return customerNumber;
}
public String geteMail() {
return eMail;
}
public void setCustomerNumber(int customerNumber) {
this.customerNumber = customerNumber;
}
public void seteMail(String eMail) {
this.eMail = eMail;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.