In: Computer Science
Create a java program that allows people to buy tickets to a concert. Using java create a program that asks for the users name, and if they want an adult or teen ticket. As long as the user wants to purchase a ticket the program with "yes" the program will continue. When the user inputs "no" the program will output the customer name, total amount of tickets, and the total price.
The adult ticket is $60 and the child ticket is $30.
import java.util.Scanner; public class TicketsPurchase { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter your name: "); String name = in.nextLine(); String choice; double total = 0; int count = 0; do { System.out.print("Are you adult or teen? "); choice = in.nextLine(); if (choice.equalsIgnoreCase("adult")) { total += 60; } else { total += 30; } ++count; System.out.print("Do you want to try again(yes or no): "); choice = in.nextLine(); } while (!choice.equalsIgnoreCase("no")); System.out.println("Customer name: " + name); System.out.println("Number of tickets: " + count); System.out.println("Total ticket price is: " + total); } }