Question: Assume that you are asked to develop a program for the XYZ Water Theme Park that will calculate the total price of ticket that need

  1. Assume that you are asked to develop a program for the XYZ Water Theme Park that will calculate the total price of ticket that need to be paid by the visitors. The price of the ticket depends on the age of the visitors as follows:

Age

Price (RM)

12 and below

30.00

Between 13 and 60

60.00

Above 60

20.00

However, if the visitor holds a membership card, the visitor is eligible for a discount of 20%. The program will prompt the user to provide his/her age and then asks whether the visitor is a member of not. Then, the price of the ticket is calculated. The user is given the option whether to continue with the next transaction or quit the program. The program implements two methods:

  1. A method called calculatePrice() that takes one parameter/argument called age to calculate the price of the ticket based on the visitors age.
  2. A method called discountedPrice() is invoke to calculate the total price after discount if the visitor has a membership card. It takes one parameter/argument of the price before discount, and return the final discounted price.

The format of the input and output is as follows:

 Assume that you are asked to develop a program for the

XYZ Water Theme Park that will calculate the total price of ticket

that need to be paid by the visitors. The price of the

WELCOME TO XYZ WATER THEME PARK ! **** How many tickets?: 2 Enter the age of visitor 1 : 65 Enter the age of visitor 2 : 15 Membership card?: [Y/N) Y Total amount: RM64.00 THANK YOU. PLEASE COME AGAIN! Do you want to continue? Please enter an integer or -1 to stop): 1 WELCOME TO XYZ WATER THEME PARK! How many tickets?: 2 Enter the age of visitor 1 : 65 Enter the age of visitor 2 : 15 Membership card?: [Y/N) N Total amount: RM80.00 THANK YOU. PLEASE COME AGAIN! Do you want to continue? Please enter an integer or -1 to stop): 5 WELCOME TO XYZ WATER THEME PARK! How many tickets?: 1 Enter the age of visitor 1 : 65 Membership card?: [Y/N) N Total amount: RM20.00 THANK YOU. PLEASE COME AGAIN! ***** Do you want to continue? Please enter an integer or -1 to stop): -1 Note: The underline texts are the input to the program a) Complete the program's main() method based on the description. import java.util.Scanner; public class ThemePark { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int age; double amt, totalAmt = 0.0; int answer; do { } while } //end main } //end class b) Complete the method to calculate the ticket price. public static double calculatePrice ) { c) Complete the method to calculate total ticket price after discount. public static double discountedPrice {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!