Question

In: Computer Science

Create a java program that allows people to buy tickets to a concert. Using java create...

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.

Solutions

Expert Solution

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);
    }
}


Related Solutions

Using Repl.it In this assignment you will create a Java program that allows a Bank customer...
Using Repl.it In this assignment you will create a Java program that allows a Bank customer to do the following: 1) Create a bank account by supplying a user id and password .2) Login using their id and password 3) Quit the program. Now if login was successful the user will be able to do the following: 1) Withdraw money. 2) Deposit money. 3) Request balance. 4) Quit the program. If login was not successful (for example the id or...
Description: The purpose of the program is to create a Java ticket purchasing program that allows...
Description: The purpose of the program is to create a Java ticket purchasing program that allows for users to log in, purchase tickets, keep records of tickets purchased, and keep information about the user. Program Requirements: The following are the program requirements: Must be fully functioning including registration, log-in, view events, and purchase tickets Tickets should be purchased using “points”, no information should be provided via the user for payment method. Default each user to an allotted number of points...
A radio station is selling concert tickets containing a random number from 1-100. Write JAVA program...
A radio station is selling concert tickets containing a random number from 1-100. Write JAVA program that prompts the user for the number of concert tickets they’d like to purchase. Use a while loop to output each ticket followed by a randomly generated number from 1-100. For example, if the user purchases 3 concert tickets, the output could look like this: Ticket 1: 79 Ticket 2: 19 Ticket 3: 61
JAVA PROGRAM Overview : You will create a card deck program that allows the player to...
JAVA PROGRAM Overview : You will create a card deck program that allows the player to shuffle a deck of cards and play a game that draws and plays cards until all cards in the deck have been used. Instructions: The application must be able to perform the following tasks : 1. At the start of a new game, it shuffles all cards using a deck shuffler 2. The player then draws X number of cards from the deck and...
You are manager of a ticket agency that sells concert tickets. You assume that people will...
You are manager of a ticket agency that sells concert tickets. You assume that people will call 4 times in an attempt to buy tickets and then give up. Each telephone ticket agent is available to receive a call with probability 0.25. If all agents are busy when someone calls, the caller hears a busy signal. Find n, the minimum number of agents that you have to hire to meet your goal of serving 95% of the customers calling to...
(JAVA) Create a program that creates a mini database of numbers that allows the user to:...
(JAVA) Create a program that creates a mini database of numbers that allows the user to: reset the database, print the database, add a number to the database, find the sum of the elements in the database, or quit. In main, you will declare an array of 10 integers (this is a requirement). Then you will define the following methods: • printArray (int[ ] arr) – this takes in an array and prints it • initArray (int[ ] arr) –...
how to create BANKACCOUNT program using Arrays in JAVA.
how to create BANKACCOUNT program using Arrays in JAVA.
JAVA Exercise BasketBall Bar Chart Write a program that allows you to create a bar chart...
JAVA Exercise BasketBall Bar Chart Write a program that allows you to create a bar chart for the active members of a basketball team during a game. (Recall: there are only 5 active players on the court per team in a standard basketball game.) Your program should do the following tasks: • Prompt the user to store the first name of the five players • Prompt the user to enter the points scored by each player a. Use a while...
Create a Java program that allows two players to play Rock, Paper, Scissors. Player 1 will...
Create a Java program that allows two players to play Rock, Paper, Scissors. Player 1 will enter an integer to determine whether they use rock, paper or scissors. Player 2 will also enter an integer to determine whether they use rock, paper or scissors. Use named constants for rock, paper and scissors and set their values as shown below. Use if-else statements to determine the results of the game. Use the named constants to compare with the player 1 and...
Using RAPTOR create a program that allows the user to input a list of first names...
Using RAPTOR create a program that allows the user to input a list of first names in on array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. the output should be a list of email address where the address is of the following form: [email protected]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT