CSCI 2003 Programming Assignment 3 website that sells theme park tickets solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Objectives:
 Practice implementing classes
 Practice if statement
 Practice printf
Assignment:
For this assignment, you are going to simulate a website that sells theme park tickets. You will need 2 separate
files: one for the ThemeParkOrder class and one for the ThemeParkOnlineTickets class.
ThemeParkOrder Class
This class will simulate an order for tickets to a theme park. This class determines a possible discount based on
the number of tickets purchased, calculates the subtotal, tax, and total, and displays the complete order.
You will need 5 instance variables for:
 Name of the theme park
 Price of an adult ticket
 Number of adult tickets purchased
 Price of a child ticket
 Number of child tickets purchased
You will need to include an argument constructor and a no-argument constructor to initialize the instance
variables.
You will need a getter and setter to access each of the instance variables (10 methods total).
You will need a method that determines the discount for the purchase based on the total number of tickets
bought and returns the discount. Use the instance variables.
Tickets Discount
Less than 3 0%
3 5%
4 10%
5 15%
More than 5 20%
2
You will need a method that calculates the subtotal for the purchases and applies the discount. It returns the
subtotal. You must call discount method for this calculation. Tax is NOT calculated here. Use the instance
variables.
You will need a method to display the complete order using printf, as seen in the sample execution. You must
call the method that calculates subtotal and the discount method. This method does not return anything. The tax
is 0.11. Use the instance variables.
ThemeParkOnlineTickets Class
This class will use the ThemeParkOrder class to simulate an order from a theme park ticket website. The
information about the prices of the tickets for each park are displayed in a table, as shown in the sample
execution.
The program will greet the customer, display the ticket options in a table, and then ask the customer to choose
the theme park they want to tickets for by enter a 1, 2, or 3. Then, based on the user’s input, it displays the
correct theme park’s prices in a table and asks the user for the number of adult tickets and child tickets they
want to purchase. Finally, it displays the all of the information for the order, using the method that displays the
order information.
Create 1 object of the ThemeParkOrder class. Use the setter methods to assign the correct values to the order
based on the chosen theme park, its prices, and the user’s input.
Use the method that displays the order information.
3
Sample Execution:
ThemeParkOnlineTickets Class Output 1:
Welcome! Please complete your ticket order below!
=================================================================
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+—+———————–+—————–+—————–+
| 1 | Universal Studios | $105.00 | $100.00 |
+—+———————–+—————–+—————–+
| 2 | Magic Kingdom | $124.00 | $118.00 |
+—+———————–+—————–+—————–+
| 3 | Epcot | $114.00 | $108.00 |
+—+———————–+—————–+—————–+
Choose a Theme Park (1 – 3): 1
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+———————–+—————–+—————–+
| Universal Studios | $105.00 | $100.00 |
+———————–+—————–+—————–+
Number of Adult Tickets: 1
Number of Child Tickets: 2
Universal Studios Ticket Order
————————————
Discount: 5%
Adult: 1 x $ 105.00
Child: 2 x $ 100.00
————————————
Subtotal: $ 289.75
Tax: $ 31.87
Total: $ 321.62
4
ThemeParkOnlineTickets Class Output 2:
Welcome! Please complete your ticket order below!
=================================================================
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+—+———————–+—————–+—————–+
| 1 | Universal Studios | $105.00 | $100.00 |
+—+———————–+—————–+—————–+
| 2 | Magic Kingdom | $124.00 | $118.00 |
+—+———————–+—————–+—————–+
| 3 | Epcot | $114.00 | $108.00 |
+—+———————–+—————–+—————–+
Choose a Theme Park (1 – 3): 2
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+———————–+—————–+—————–+
| Magic Kingdom | $124.00 | $118.00 |
+———————–+—————–+—————–+
Number of Adult Tickets: 3
Number of Child Tickets: 4
Magic Kingdom Ticket Order
————————————
Discount: 20%
Adult: 3 x $ 124.00
Child: 4 x $ 118.00
————————————
Subtotal: $ 675.20
Tax: $ 74.27
Total: $ 749.47
5
ThemeParkOnlineTickets Class Output 3:
Welcome! Please complete your ticket order below!
=================================================================
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+—+———————–+—————–+—————–+
| 1 | Universal Studios | $105.00 | $100.00 |
+—+———————–+—————–+—————–+
| 2 | Magic Kingdom | $124.00 | $118.00 |
+—+———————–+—————–+—————–+
| 3 | Epcot | $114.00 | $108.00 |
+—+———————–+—————–+—————–+
Choose a Theme Park (1 – 3): 3
+———————–+—————–+—————–+
| THEME PARK | ADULT TICKET | CHILD TICKET |
+———————–+—————–+—————–+
| Epcot | $114.00 | $108.00 |
+———————–+—————–+—————–+
Number of Adult Tickets: 2
Number of Child Tickets: 0
Epcot Ticket Order
————————————
Discount: 0%
Adult: 2 x $ 114.00
Child: 0 x $ 108.00
————————————
Subtotal: $ 228.00
Tax: $ 25.08
Total: $ 253.08
6
Requirements:
 Use an updated comment block
 Your program should use the following comment block at the very beginning of your program.
// Name: Your Name Date Assigned: Fill in
//
// Course: CSCI 2003 60357 Date Due: Fill in
//
// Instructor: Ms. Greer
//
// File name: Fill in
//
// Program Description: Brief description of what the program does.
 Use appropriate comments throughout the program
 Make good use of whitespace
 Your output should look exactly like the sample output if using the same data.
Deliverables:
 ThemeParkOrder.java file
 ThemeParkOnlineTickets.java file
 Upload 2 files to Moodle
7
Grading:
Total Points 15 points
ThemeParkOrder Class 9 points
Declare instance variables correctly 1 point
Constructors are correct 1 point
Getters and setters are correct 1 point
Discount method is correct 1 point
Correctly determines discount 0.5 point
Returns correct discount 0.5 point
Subtotal method is correct 2 point
Calculates subtotal correctly 0.5 point
Applies discount to subtotal correctly 0.5 point
Uses the discount method 0.5 point
Returns discounted subtotal 0.5 point
Display order method is correct 3 point
Uses printf to format 0.5 point
Uses the method that calculates subtotal 1 point
Calculates tax and total correctly 1 point
Values are formatted correly 0.5 point
ThemeParkOnlineTickets Class 6 points
Displays theme park info in a table 1 point
Gets park choice correctly 1 point
Uses park choice to display the correct park info 1 point
Creates 1 object 1 point
Initializes objects instance variables correctly 1 point
Displays order using the print order method 1 point
Not enough comments/whitespace -1 point
Output does not match the sample executions given in the
assignment
-1 point
Bad variable names, method names, and/or class names -1 point