Question: USING JAVA and Java.util.scanner, and one main class only We need a program that will calculate the price of cinema tickets. To write the program,
USING JAVA and Java.util.scanner, and one main class only
We need a program that will calculate the price of cinema tickets. To write the program, please follow the questions 1 to 3. Note that the price of 1 ticket is given according to the row number in the following table
|
|
| Row | 1 to 5 | 6 to 10 | >10 |
| Price of 1 ticket | 30 | 20 | 15 |
1- Write a method that will accept a char representing the type of the ticket (s or S for student and m or M for military) and return the discount percentage. The discount percentage is 20% for students and 50% for military and 0 otherwise.
2- Write a method called calculateTotal that will accept the number of tickets, the row code and the discount rate and return the total to be paid. Total= number of tickets*price of 1 ticket *( 1-discount)
3- Write a driver program that will ask the user to enter a char representing type of the ticket, the row number and an integer representing the number of tickets and display the total to be paid for those tickets.
Sample run1: Enter the type of your ticket (s for student, m for military, or any other letter for normal ticket): s Enter the row number: 6 Enter the number of tickets: 1 The total to be paid is : 16$
Sample run2: Enter the type of your ticket (s for student, m for military, or any other letter for normal ticket): g Enter the row number: 3 Enter the number of tickets: 2 The total to be paid is : 60$
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
