Answer to Question #203726 in Java | JSP | JSF for Waleed

Question #203726

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:


1
Expert's answer
2021-06-05T23:55:14-0400
public class CustomerPurchases {
	private static int customerNumber;
	private int quantity;
	private String firstName, surname, product;
	private double price;


	public int getCustomerNumber() {
		return customerNumber;
	}
	public void setCustomerNumber(int customerNumber) {
		this.customerNumber = customerNumber;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	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;
	}
	static class Printing {
		public static void printlnDetails(CustomerPurchases cp) {
			System.out.println("Customer invoice of " + cp.getFirstName() + " " + cp.getSurname() + " is : $ "
					+ cp.getPrice() * cp.getQuantity());
		}




		public static void customerPurchaseReport(CustomerPurchases cp) {
			double price = cp.getPrice();
			System.out.println("REPORT OPTION");
			System.out.format("%s %.2f \n", "PERCENTAGE TAX 15% : $", price * 0.15);
			System.out.format("%s %.2f \n", "COMMISSION 8.5% : $", price * 0.085);
			System.out.format("%s %.2f \n", "DISCOUNT 10% : $", price * 0.1);
			System.out.format("%s %.2f \n", "TOTAL (Price + Tax) – (Discount + Commission) = $",
					(1 + 0.15 - 0.1 - 0.085) * price);
		}




	}




	public static void main(String args[]) {
		CustomerPurchases guitar = new CustomerPurchases();
	}




}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS