Question 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.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package customer_purchases;
/**
*
* @author Student
*/
import java.util.Scanner;
class Printing{
Customer_Purchases customer = new Customer_Purchases();
void Details(int number, String first_name, String surname, String product, double price, int quantity){
customer.setCustomerNumber(number);
customer.setPrice(price);
customer.setQuantity(quantity);
customer.setSurname(surname);
customer.setfirstName(first_name);
customer.setProduct(product);
}
void Print_Details(){
System.out.println("\tCUSTOMER INVOICE\t");
System.out.println("\t-------------------------------------\t");
System.out.println("\tCUSTOMER NUMBER:\t" +customer.getNumber());
System.out.println("\tCUSTOMER FIRST NAME:\t" +customer.getFirstName());
System.out.println("\tCUSTOMER SURNAME:\t" +customer.getSurname());
System.out.println("\tPRODUCT:\t" +customer.getProduct());
System.out.println("\tPRODUCT PRICE:\t" +customer.getPrice());
System.out.println("\tPRODUCT QUANTITY:\t" +customer.getQuantity());
}
void Customer_Purchase_Report(){
double tax = 0.15 * customer.getPrice();
double commission = 0.085 * customer.getPrice();
double discount = 0.1 * customer.getPrice();
double total = (customer.getPrice() + tax) - (discount + commission);
System.out.println("\tCUSTOMER PURCHASE REPORT\t");
System.out.println("\tPRODUCT PRICE:\t" +customer.getPrice());
System.out.println("\tTAX:\t" +tax);
System.out.println("\tCOMMISSION:\t" +commission);
System.out.println("\tDISCOUNT:\t" +discount);
System.out.println("\tTOTAL:\t" +total);
}
}
public class Customer_Purchases {
private int customer_number;
private String first_name;
private String surname;
private String product;
private double price;
private int quantity;
void setCustomerNumber(int n){
customer_number = n;
}
void setfirstName(String s){
first_name = s;
}
void setSurname(String su){
surname = su;
}
void setProduct(String p){
product = p;
}
void setPrice(double pr){
price = pr;
}
void setQuantity(int q){
quantity = q;
}
int getNumber(){
return customer_number;
}
String getFirstName(){
return first_name;
}
String getSurname(){
return surname;
}
String getProduct(){
return product;
}
double getPrice(){
return price;
}
int getQuantity(){
return quantity;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int customer_number;
String first_name;
String surname;
String product;
double price;
int quantity;
Scanner input = new Scanner(System.in);
System.out.println("\tEnter Customer number:\t");
customer_number = input.nextInt();
System.out.println("\tEnter Customer First Name:\t");
first_name = input.next();
System.out.println("\tEnter Customer Surname:\t");
surname = input.next();
System.out.println("\tEnter Product:\t");
product = input.next();
System.out.println("\tEnter Product Price:\t");
price = input.nextDouble();
System.out.println("\tEnter Product Quantity:\t");
quantity = input.nextInt();
Customer_Purchases customer = new Customer_Purchases();
customer.setCustomerNumber(10111);
customer.setPrice(5000);
customer.setQuantity(2);
customer.setSurname(surname);
customer.setfirstName(surname);
customer.setProduct(product);
Printing print = new Printing();
print.Details(customer_number, first_name,surname, product, price, quantity);
print.Print_Details();
System.out.println(" ");
print.Customer_Purchase_Report();
}
}
Comments
Leave a comment