Question: Write a Java program to use classes and objects to implement Movie Ticketing System problem in PA05/Q2 Create a class Customer with the following instance
Write a Java program to use classes and objects to implement Movie Ticketing System problem in PA05/Q2 Create a class Customer with the following instance variables:
- String: customerName ie. First name Last name
- String: memberID // this could be null for non-members
- String movieName
- double: memberDiscount // as %
- double: movieTicketCost
- double: discountAmount // calculated value from above values
- double: salesTaxAmount // calculated value from above values
- double: netMovieTicketCost // calculated value from above values
The class shall have a final instance variable of type double, named SALES_TAX_PERCENTAGE and initialized to 7.4%.
Define 2 overloaded constructors to create objects, as follows:
Customer(customerName,movieName, movieTicketCost)
Customer(customerName,movieName, memberID, movieTicketCost)
When the first constructor gets invoked ie. non-member customers, set the memberID and memberDiscount to null and 0%.
When the second constructor with memberID gets invoked, set the memberID and initialize the memberDiscount to a default 5%.
Implement getter and setter methods for all the instance variables. The class shall have the following class methods:
- CalculateDiscount() // discount % will be scratch card discount + memberdiscount
- CalculateSalesTax () - CalculateNetMovieTicketCost()
This method will call CalculateDiscount() and CalculateSalesTax() and set the discountAmount and salesTax instance variables. Then calculate net movie ticket cost as :
netMovieTicketCost = movieTicketCost - discountAmount + salesTaxAmount
- toString() This method must display the output in the following format: Customer Name: Movie Ticket Cost: Total Discount: Sales Tax: Net Movie Ticket Cost Amount: Write a test class TestCustomer with main() method to test the Customer class implementation. Instantiate 3 Customer class objects as follows:
cust1 = Customer(John Doe, Movie 1, 12.99)
cust2 = Customer(David Fields, Movie 2, 8877, 13.99)
cust3 = Customer(Carol smith, Movie 3, 5.75)
Calculate and display the net movie ticket cost for each of the above customer objects. Then make the cust3 to become a member by setting the memberID using the corresponding setter method. i.e. cust3.setMemberID(9250) Again calculate and display the net movie ticket cost for each of the above customer objects. Evaluation Criteria:
1. You must use the class template in your program classes
2. The program must not have any compilation or runtime errors
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
