Question: Another problem with my output! The question: A retail store has a preferred customer plan where customers can earn discounts on all their purchases. The
Another problem with my output!
The 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.
The code
class Customer
{
private String name;
private double itemNo;
private double quantity;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public double getItemNo()
{
return itemNo;
}
public void setItemNo(double itemNo)
{
this.itemNo = itemNo;
}
public double getQuantity()
{
return quantity;
}
public void setQuantity(double quantity)
{
this.quantity = quantity;
}
}
class PreferredCustomer extends Customer
{
double purchases;
double discount;
public PreferredCustomer()
{
purchases = 0.00;
discount = 0.00;
}
public PreferredCustomer(double purchases, double discount)
{
this.purchases = purchases;
this.discount = discount;
}
public double getPurchases()
{
return purchases;
}
public void setPurchases(double purchases)
{
this.purchases = purchases;
}
public double getDiscount()
{
if (purchases >= 500.00 && purchases
discount = 0.05;
else if (purchases > 1000.00 && purchases
discount = 0.06;
else if (purchases >1500.00 && purchases
discount = 0.07;
else
discount = 0.10;
return discount;
}
}
class testPreferredCustomer
{
public static void main(String[] args)
{
PreferredCustomer pCust = new PreferredCustomer();
pCust.setPurchases(600.00);
System.out.println(" Amount purchase: " + pCust.getPurchases());
System.out.println("Discount: " + pCust.getDiscount());
System.out.println("Total Amount: " + (pCust.getPurchases() - (pCust.getPurchases()*pCust.getDiscount())));
pCust.setPurchases(1600.00);
System.out.println(" Amount purchase: " + pCust.getPurchases());
System.out.println("Discount: " + pCust.getDiscount());
System.out.println("Total Amount: " + (pCust.getPurchases() - (pCust.getPurchases()*pCust.getDiscount())));
}
}
The output

Problems Detected: The contents of your standard output is incorrect. Given the following was entered from the keyboard: Bebe Hart 5041 Crystal Bank Oconomowoc, Minnesota 551714 218-775-5416 567310954 yes 1894 you displayed instead of Enter name of customer:Enter address of customer:Enter phone number of customer:Enter customer number:Enter yeso --does the customer want to recieve mail?:Enter amount customer has spent: Customer: Name: Bebe Hart Address: 5041 Crystal Bank Oconomowoc, Minnesota 551714 Phone Number: 218-775-5416 Customer Number: 567310954 Recieve Mail?: true Amount Purchased: $1894.00 Percent off: 7% Failed 5 out of 5 test runs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
