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

Java Programming Challenge PreferredCustomer Class A retail store has a preferre

ID: 3767177 • Letter: J

Question

Java Programming Challenge

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 in all future purchase.

* When a preferred customer spends $1,500, he or she gets a 7 percent discount in all future purchase.

* When a preferred customer spends $2,000 or more, he or she gets a 10 percent discount in all future purchase.

Design a class named PreferredCustomer, which extends the Customer class you created in Challenge 7 (See code below). 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.

***Customer Class completed from Challenge 7, please incorporate this code into the Preferred Customer Class.

class Customer extends Person
{
String CustomerNumber;
boolean mail;
public Customer(String name, String addr, String phone,String number,boolean mail)
{
super(name, addr, phone);
this.CustomerNumber=number;
this.mail=mail;
}
public String getCustomerNumber()
{
return CustomerNumber;
}
public void setCustomerNumber(String CustomerNumber)
{
this.CustomerNumber = CustomerNumber;
}
public boolean isMail()
{
return mail;
}
  
public void setMail(boolean mail)
{
this.mail = mail;
}
public static void main(String args[])
{
Scanner kb = new Scanner(System.in);
System.out.println("Enter the customer's name: ");
String name=kb.nextLine();
System.out.println("Enter the customer's address: ");
String address=kb.nextLine();
System.out.println("Enter the customer's phone number: ");
String phone=kb.nextLine();
System.out.println("Enter customer number: ");
String customerNumber=kb.nextLine();
System.out.println("The customer wants to be added to the "
+ "mailing list? Enter 'true' or 'false' : ");

boolean mail=kb.nextBoolean();
  
Customer cust = new Customer(name,address,phone,customerNumber,mail);
  
System.out.println("Customer: ");
System.out.println("Name: "+cust.name);
System.out.println("Address: "+cust.address);
System.out.println("Phone number: "+cust.phone);
System.out.println("Customer number: "+cust.CustomerNumber);
System.out.println("Added to mailing list?: "+cust.mail);
}
}

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

}

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