Answer:
import java.util.Scanner;
public class BusTicketCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Get customer information
System.out.println("Enter customer name:");
String name = input.nextLine();
System.out.println("Enter mailing address:");
String address = input.nextLine();
System.out.println("Enter telephone number:");
String telephone = input.nextLine();
// Get package and number of tickets
System.out.println("Select a package (A, B, or C):");
String packageOption = input.nextLine();
while (!packageOption.equals("A") && !packageOption.equals("B") && !packageOption.equals("C")) {
System.out.println("Invalid package selected. Please choose A, B, or C:");
packageOption = input.nextLine();
}
System.out.println("Enter number of tickets:");
int numTickets = input.nextInt();
// Calculate ticket price based on package and number of tickets
double ticketPrice = 0;
if (packageOption.equals("A")) {
ticketPrice = numTickets * 19.95;
} else if (packageOption.equals("B")) {
ticketPrice = numTickets * 25.95;
} else if (packageOption.equals("C")) {
if (numTickets >= 10) {
ticketPrice = numTickets * 21.95;
} else {
ticketPrice = numTickets * 25.95;
}
}
// Display ticket information
System.out.println("\\Ticket Information:");
System.out.println("Name: " + name);
System.out.println("Address: " + address);
System.out.println("Telephone: " + telephone);
System.out.println("Package: " + packageOption);
System.out.println("Number of Tickets: " + numTickets);
System.out.println("Total Price: $" + ticketPrice);
}
}
This took a while as I am not extremely good at coding.
Step-by-step explanation: