JAVA PreferredCustomer Class A retail store has a preferred

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 percent discount on all
future purchases.
• When a preferred customer spends $1,000, he or she gets a 6 percent discount on all
future purchases.
• When a preferred customer spends $1,500, he or she gets a 7 percent discount on all
future purchases.
• When a preferred customer spends $2,000 or more, he or she gets a 10 percent discount
on all future purchases.


Design a class named PreferredCustomer, which extends the Customer class you created 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.

Hello I need help with the questions above this is what I have so far, I dont know what I am doing wrong I keep getting an error message can someone help me please, Thank you in advance:

Person.java

==============================================================================================

Customer.java

====================================================================================

====================================================================================

=========================================================================================================================

This is suppose to be the output:

Challenge 8 (you need 4 classes Customer, Person, Preferred customer and Demo)

Output

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

Solution

class Person {
//Members of the class person
String name;
String address;
String telephoneNumber;

//Constructors for the data members
public Person(String name, String address, String telephoneNumber){
this.name = name;
this.address = address;
this.telephoneNumber = telephoneNumber;
}
//\"setName\" stores the parameter \"name\"
public void setName(String name){
this.name = name;
}
//\"setAddress\" stores the parameter \"address\"
public void setAddress(String address){
this.address = address;
}
//\"setTelephoneNumber\" stores the parameter value for \"telephoneNumber\"
public void setTelephoneNumber(String telephoneNumber){
this.telephoneNumber = telephoneNumber;
}
//\"getName\" returns the parameter value \"name\"
public String getName(){
return name;
}
//\"getAddress\" returns the parameter value \"address\"
public String getAddress(){
return address;
}
//\"getPhoneNumber\" returns the parameter value \"telephoneNumber\"
public String getPhoneNumber(){
return telephoneNumber;
}
public String toString(){
String person = \"Name: \" + getName() + \"\ Address: \" + getAddress() +
\"\ PhoneNumber: \" + getPhoneNumber();
return person;
}

}

class Customer extends Person {
String customerNumber;
boolean mailingList;

//Constructors
public Customer(String name, String address, String telephoneNumber, String customerNumber, boolean mailingList){
super(name, address, telephoneNumber);
this.customerNumber = customerNumber;
this.mailingList = mailingList;
}
//\"setCustomerNumber\" stores the parameter value \"customerNumber\"
public void setCustomerNumber(String customerNumber){
this.customerNumber = customerNumber;
}
//\"setMailOnOff\" stores the parameter value for \"mailingList\"
public void setMailOnOff(boolean mailingList){
this.mailingList = mailingList;
}
//\"getMailOnOff\" returns the parameter value \"mailingList\"
public String getMailOnOff()
{
   if(mailingList)
return \"Yes\";
   else
   return \"No\";
}
//\"getCustomerNumber\" returns the parameter value \"customerNumber\"
public String getCustomerNumber(){
return customerNumber;
}
public String toString(){
String customer = super.toString() + \"\ Customer Number: \"
+ getCustomerNumber() + \"\ Customer MailList: \" +
getMailOnOff();
return customer;
}
}
class PreferredCustomer extends Customer {

double purchase;
double discount;

//Constructor
public PreferredCustomer(String name, String address, String telephoneNumber,
String customerNumber, boolean mailingList, double purchase)
   {
super(name, address, telephoneNumber, customerNumber, mailingList);
this.purchase = purchase;

//\"setDiscount\" method
if(purchase >= 2000)
setDiscount(0.10);
else if(purchase >= 1500)
setDiscount(0.07);
else if(purchase >= 1000)
setDiscount(6);
else
setDiscount(0.05);

}
//\"setPurchase\" stores the parameter value \"setPurchase\"
public void setPurchase(double purchase){
this.purchase = purchase;
}
//\"setPurchase\" stores the parameter value \"setPurchase\"
private void setDiscount(double discount){
this.discount = discount;
}
//\"getPurchase\" returns purchase value
public double getPurchase(){
return purchase;
}
//\"getDiscount\" returns discount value
public double getDiscount(){
return discount;
}
public String toString(){
String preferredCustomer = super.toString() + \"\ Purchase\"
+ getPurchase() + \"\ Discount \" + getDiscount();
return preferredCustomer;
}
}
public class PreferredCustomerDemo {
public static void main(String[] args){
PreferredCustomer preferredCustomer = new PreferredCustomer(\"Julie James\", \"123 Main Street\", \"555-1212\", \"147-A049\", true , 1750);
System.out.println(preferredCustomer.toString());
}
}

Output:

Name: Julie James
Address: 123 Main Street
PhoneNumber: 555-1212
Customer Number: 147-A049
Customer MailList: Yes
Purchase1750.0
Discount 0.07

Necessary chnages marked as bold.

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
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
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
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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site