EagleBank Arena sells tickets to various entertainment focused events. You have
ID: 3666018 • Letter: E
Question
EagleBank Arena sells tickets to various entertainment focused events. You have been tasked with creating a program to allow a customer to purchase one ticket. Management has provided you with the following rules to determine how to calculate ticket cost for one ticket: All tickets have a base cost of $10.60 Based on seat number selected, an additional seat cost is added to the base cost as follows: o Tickets for seats numbered 1-55, there is no seat cost o Tickets for seats numbered 56-106 add a seat cost of $7.45 o Tickets for seats numbered 107-206 add a seat cost of $14.30 o Tickets for seats numbered 207-306 add a seat cost of $35.16 All tickets have a convenience fee based on the delivery method as follows: o For tickets that are emailed, a 1% convenience fee is added to the total cost of the ticket o For tickets that are shipped, a 3% convenience fee is added to the total cost of the ticket Create a program that will ask the user for the name of the person purchasing the ticket, seat number, and delivery method for one ticket to be purchased. If at any point an invalid value is entered, inform the user a ticket cannot be purchased at this time and they must contact the Ticket Office. Then, end the program. However, if all valid values are entered, calculate the total ticket cost and display a wellformatted receipt including the name of the person purchasing the ticket, seat number, delivery method, ticket base cost, seat cost, convenience fee, and total cost. 1) Create a defining diagram that shows the input, processing, and output 2) Create a solution algorithm using pseudocode 3) Show testing using the desk checking table method, to include test data, expected results, and a desk checking table. Make sure your desk checking considers multiple cases including both valid and invalid test data to prove your algorithm will work in all cases
Explanation / Answer
Ticket.java
package ticketbook;
public class Ticket {
private final double basePrice = 10.6;
private double seatCost;
private double convenienceFee;
private int seatNumber;
private String purchaser;
private String deliveryMethod;
private double totalCost;
public Ticket(double seatCost, double convenienceFee, int seatNumber, String purchaser, String deliveryMethod,
double totalCost) {
super();
this.seatCost = seatCost;
this.convenienceFee = convenienceFee;
this.seatNumber = seatNumber;
this.purchaser = purchaser;
this.deliveryMethod = deliveryMethod;
this.totalCost = totalCost;
}
public double getSeatCost() {
return seatCost;
}
public void setSeatCost(double seatCost) {
this.seatCost = seatCost;
}
public double getConvenienceFee() {
return convenienceFee;
}
public void setConvenienceFee(double convenienceFee) {
this.convenienceFee = convenienceFee;
}
public int getSeatNumber() {
return seatNumber;
}
public void setSeatNumber(int seatNumber) {
this.seatNumber = seatNumber;
}
public String getPurchaser() {
return purchaser;
}
public void setPurchaser(String purchaser) {
this.purchaser = purchaser;
}
public String getDeliveryMethod() {
return deliveryMethod;
}
public void setDeliveryMethod(String deliveryMethod) {
this.deliveryMethod = deliveryMethod;
}
public double getTotalCost() {
return totalCost;
}
public void setTotalCost(double totalCost) {
this.totalCost = totalCost;
}
public double getBasePrice() {
return basePrice;
}
@Override
public String toString() {
return "Purchaser=" + purchaser + " Base Price=" + basePrice + " Seat Cost=" + seatCost + " Convenience Fee=" + convenienceFee
+ " Seat Number=" + seatNumber + " Delivery Method=" + deliveryMethod
+ " Total Cost=" + totalCost;
}
}
TicketBook.java
package ticketbook;
import java.util.InputMismatchException;
import java.util.Scanner;
public class TicketBook {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter name of the person purchasing the ticket");
String name = scanner.next();
System.out.println("Enter seat number");
int seatNumber = 0;
try {
seatNumber = scanner.nextInt();
} catch (InputMismatchException e) {
e.printStackTrace();
}
if (seatNumber > 306 || seatNumber < 1)
throw new Exception(
"Invalid seat number. Ticket cannot be purchased at this time. Please contact the Ticket Office.");
System.out.println("Enter delivery method. It must be email or ship");
String deliveryMethod = scanner.next();
if (!(deliveryMethod.equals("email") || deliveryMethod.equals("ship")))
throw new Exception(
"Invalid delivery method. Ticket cannot be purchased at this time. Please contact the Ticket Office.");
double seatCost = 0, convenience, totalCost, basePrice = 10.6, totalSeatCost;
if (seatNumber <= 55)
seatCost = 0;
else if (seatNumber <= 106)
seatCost = 7.45;
else if (seatNumber <= 206)
seatCost = 14.3;
else if (seatNumber <= 306)
seatCost = 35.16;
totalSeatCost = basePrice + seatCost;
if (deliveryMethod.equals("email"))
convenience = 0.01 * totalSeatCost;
else
convenience = 0.03 * totalSeatCost;
totalCost = convenience + totalSeatCost;
Ticket ticket = new Ticket(totalSeatCost, convenience, seatNumber, name, deliveryMethod, totalCost);
System.out.println(ticket);
}
}
I AM NOT SURE WHAT DO YOU MEAN BY DESK CHECKING TABLE. CAN YOU PLEASE ELABORATE? I WILL EDIT MY ANSWER THEN
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.