__Java Code__

__Problem 03: Ticket prices for a tourist attraction__

A tourist attraction offers three types of tickets:

- Regular adult tickets at 3.000 BHD per person, with a reduction of 10% for group of at least five persons.
- Student tickets at 2.500 BHD per person.
- Family tickets for two adults and two or more children. The price is 7.500 BHD with an additional 1.500 BHD for each child beyond two children.

Write a program that calculates the total price of tickets. The program displays a menu with three options, lets the user select option, and then asks for the number of people in the party. It should then display the total amount due.

The class CMPE160_HW2_part3 contains starter code for you to complete.

package CMPE160_HW2;

public class CMPE160_HW2_part3 {

public static void main(String[] args) {

// in this main method, print the message prompting the user to input a choice.

//then you will call the calculatePrice method with their input as arguments to the method.

}

//modify the below methods as appropriate

//this method should have two parameters:

//1. the first paramets indicates the choice

//2. the second paramets indicates a number. If this is a regular or student ticket, this number would represent the number of tickets.

//if it is a family ticket, this would indicate the number of children

static double calculatePrice() {

}

}

Output example:

This program calculates your ticket price for the tourist attraction.

1. Regular ticket

2. Student ticket

3. Family ticket

4. Quit

Enter your choice (1-4): 1

Enter the number of regular tickets: 8

The cost for this is BHD 21.600

This program calculates your ticket price for the tourist attraction.

1. Regular ticket

2. Student ticket

3. Family ticket

4. Quit

Enter your choice (1-4): 3

Enter the number of children: 5

The cost for this is BHD 12.000

Community Answer

【General guidance】The answer provided below has been developed in a clear step by step manner.Step1/3In this java code, there is the main method which contains the infinite while loop which contains the menu, and then the choice is asked from the user. If the user enters 4 that will terminate the loop. If the user enters 1 then the user is asked the number of regular tickets he wants and then the calculatePrice() method is called, if the user enters 2 then the number of a student ticket is asked from the user, and calculatePrice() is called, or else if the user enters 3 then the number of children is taken from the user and the calculatePrice() is called. There is a function called calculatePrice() which takes in two parameters: choice and the number of tickets or children. Inside the method, a switch statement is written with the choice as a parameter and in case 1 the sum of the regular ticket is calculated and if the number is greater than 5 then a 10% discount is given. If the case is 2 then the sum of the student tickets is calculated and if the case is 3 then the price of the family ticket is calculated and if the number of children is greater than 2 then 1.5 BHD is charged for each child. Outside the switch statement, the sum is returned. Explanation:Explanation of code.Step2/3The required java code.import java.util.*;public class CMPE160_HW2_part3 {public static void main(String[] args) { //main methodScanner sc=new Scanner(System.in); //scanner classint choice=0,n=0; //local variableswhile(true) { //infinite loop//menuSystem.out.print("\nThis program calculates your ticket price for the tourist attraction.\r\n"+ "1. Regular ticket\r\n"+ "2. Student ticket\r\n"+ "3. Family ticket\r\n"+ "4. Quit\r\n"+ "Enter your choice (1-4): " ... See the full answer