n 1
(Marks: 40)
Sam runs a local musical equipment store in your neighbourhood. He has contracted you to create
an interactive application that will assist him with customer purchases. Create a class named
Customer Purchases that will contain get and set methods for a customer number, first name,
surname, product, price and quantity. Create a separate class called Printing that will include a
method called Print Details, that will print the Customer Invoice. In the Printing class include
another method called Customer Purchase Report which will display the following information:
REPORT OPTION
PERCENTAGE
TAX
15%
COMMISSION
8.5%
DISCOUNT
10%
TOTAL
(Price + Tax) – (Discount + Commission)
In your main class, capture all the customer purchase details required to produce the reports.
Sample Screenshot 1
Sample Screenshot 2
Sample Screenshot 3
© The Independent Institute of Education (Pty) Ltd 2021
public class CustomerPurchases {
private int customerNumber;
private String firstName;
private String surname;
private String product;
private double price;
private int quantity;
public int getCustomerNumber() {
return customerNumber;
}
public void setCustomerNumber(int customerNumber) {
this.customerNumber = customerNumber;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
}
public class Printing {
public void printDetails(CustomerPurchases customerPurchases) {
System.out.println("\nCustomer Invoice:");
System.out.println(customerPurchases.getFirstName() + " "
+ customerPurchases.getSurname() + "(" + customerPurchases.getCustomerNumber() + ")");
System.out.println(customerPurchases.getProduct() + " " + customerPurchases.getQuantity()
+ " $" + customerPurchases.getPrice());
}
public void customerPurchaseReport(CustomerPurchases customerPurchases) {
System.out.println("\nReport");
double tax = customerPurchases.getPrice() * 0.15;
double commission = customerPurchases.getPrice() * 0.085;
double discount = customerPurchases.getPrice() * 0.1;
System.out.println("Price " + customerPurchases.getPrice());
System.out.println("Tax " + tax);
System.out.println("Commission " + commission);
System.out.println("Discount " + discount);
System.out.println("Total " + ((customerPurchases.getPrice() + tax) - (discount + commission)));
}
}
public class Main {
public static void main(String[] args) {
CustomerPurchases customerPurchases = new CustomerPurchases();
Printing printing = new Printing();
customerPurchases.setCustomerNumber(1984);
customerPurchases.setFirstName("George ");
customerPurchases.setSurname("Orwell");
customerPurchases.setProduct("Camera");
customerPurchases.setPrice(100);
customerPurchases.setQuantity(1000);
printing.printDetails(customerPurchases);
printing.customerPurchaseReport(customerPurchases);
}
}
Comments
Leave a comment