Knowee
Questions
Features
Study Tools

Develop a Java program for a ticket pricing system. Prompt the user to enter their age and the type of ticket they want to purchase (1 for regular, 2 for VIP). Use if-then-else statements to calculate the ticket price based on the following criteria:Regular Ticket Prices:Age 0-5: FreeAge 6-12: $10Age 13-18: $15Age 19 and above: $20VIP Ticket Prices:Age 0-5: $5Age 6-12: $15Age 13-18: $20Age 19 and above: $30

Question

Develop a Java program for a ticket pricing system. Prompt the user to enter their age and the type of ticket they want to purchase (1 for regular, 2 for VIP). Use if-then-else statements to calculate the ticket price based on the following criteria:Regular Ticket Prices:Age 0-5: FreeAge 6-12: 10Age1318:10Age 13-18: 15Age 19 and above: 20VIPTicketPrices:Age05:20VIP Ticket Prices:Age 0-5: 5Age 6-12: 15Age1318:15Age 13-18: 20Age 19 and above: $30

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple Java program that implements the ticket pricing system you described:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter your age:");
        int age = scanner.nextInt();

        System.out.println("Enter the type of ticket you want to purchase (1 for regular, 2 for VIP):");
        int ticketType = scanner.nextInt();

        int ticketPrice;

        if (ticketType == 1) {
            if (age <= 5) {
                ticketPrice = 0;
            } else if (age <= 12) {
                ticketPrice = 10;
            } else if (age <= 18) {
                ticketPrice = 15;
            } else {
                ticketPrice = 20;
            }
        } else {
            if (age <= 5) {
                ticketPrice = 5;
            } else if (age <= 12) {
                ticketPrice = 15;
            } else if (age <= 18) {
                ticketPrice = 20;
            } else {
                ticketPrice = 30;
            }
        }

        System.out.println("Your ticket price is: $" + ticketPrice);
    }
}

This program first prompts the user to enter their age and the type of ticket they want to purchase. It then uses if-then-else statements to calculate the ticket price based on the user's age and ticket type. Finally, it prints out the calculated ticket price.

This problem has been solved

Similar Questions

The program you will develop needs to accept input from a source, run the input through several comparisons, and then calculate an output. You will use variables, assignments, if-else functions, and arrays.In this scenario, you need to create a program that will take a user's age and determine a ticket price based on their age.The standard ticket price is $10.00.Minors (those under the age of 18) will pay $1.00 less than the standard ticket price.Seniors (those over the age of 65) will receive a 15% discount.

Consider a ticket reservation system that allows users to book tickets for various destinations. Each ticket has details such as passenger name, destination, ticket price, and passenger age. The ticket prices are calculated based on the passenger's age, with children (age <= 12) receiving a 50% discount, senior citizens (age >= 60) receiving a 30% discount, and others paying the regular price. The system also tracks the confirmation status of each ticket.Design a Java program that implements this ticket reservation system. The program should prompt the user to input details for multiple tickets, including passenger name, destination, ticket price, and passenger age. It should then calculate and display the total amount of tickets booked for confirmed tickets alone, considering the discounted prices based on passenger age.Write the Java code for the ticket reservation system and demonstrate its functionality with a sample input/output scenario.Sample Input: 3  //No of tickets to book Ravi  // NameDelhi // Destination2000  // Price70 // Age Manu  // NameDelhi // Destination2000  // Price9 // Age Priya  // NameDelhi // Destination2000  // Price40 // Ageconfirm   // Do you want to confirm or cancel ticket 1? (confirm/cancel)cancel  // Do you want to confirm or cancel this ticket 2? (confirm/cancel)confirm // Do you want to confirm or cancel this ticket 3? (confirm/cancel)Sample Output:3400.0  // Total Amount of Confirmed Tickets

Needs to be in MIPSzy only. The program you will develop needs to accept input from a source, run the input through several comparisons, and then calculate an output. You will use variables, assignments, if-else functions, and arrays.In this scenario, you need to create a program that will take a user's age and determine a ticket price based on their age.The standard ticket price is $10.00.Minors (those under the age of 18) will pay $1.00 less than the standard ticket price.Seniors (those over the age of 65) will receive a 15% discount.

For a movie ticket booking system, write a program in Java to implement the process. Some persons need First class seating system (Option1). Another option is Second class seating system (Option 2). Implement this process using Polymorphism and inheritance. In the ‘First’ class get the inputs like movie name, Theater Name, Show Date, and Number of Seats. If the date is 2022-11-20 print the price as 500 else print the price as 1000 for each seat. In the ‘Second’ class Get the inputs like movie name, Theater Name, Show Date, and Number of Seats. Cost of each ticket is Rs.200. If theater name is “mnbjhrbjbj” apply coupon code and reduce Rs.500 from actual price. Print all the details as a report.

The ticket price for adults is IDR 100.000, for children aged 4 - 12 is 25% less than for adults, and for children below 4 years old is free. Jon buys a ticket for himself, his wife, and children of 10 and 2 years of age. How much must he pay for the tickets?

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.