How to complete the MovieTheater program below that prompts the user for the number of adult and
Fantastic news! We've Found the answer you've been seeking!
Question:
- How to complete the MovieTheater program below that prompts the user for the number of adult and child tickets to purchase as well as whether the movie showing is a matinee. Adult tickets cost $12 and child tickets cost $10. There is a $3 discount for each matinee ticket.
public class MovieTheater {
public static final int ADULT_PRICE = 12;
public static final int CHILD_PRICE = 10;
public static final int MATINEE_DISCOUNT = 3;
public static void main(String[] args) {
}
}
- Prompt the user for the number of each type of ticket. Output "Invalid value" and exit the program if either number of tickets is less than 0.
- Prompt the user for whether the movie is a matinee. If the user enters anything that starts with y or Y, it is a matinee. Otherwise, it is not a matinee.
- Output the price of the tickets formatted as $xx.00 as shown in the examples below. This can be done by simply using String concatenation - you don't need to use printf().
- Provide "javadoc" for the class, main method, and class constants.
- See the TaxCalculator program for an example of how to complete the program and document it using javadoc comments.
$ java MovieTheater
Adult tickets: 2
Child tickets: 3
Matinee (y,n): n
Ticket price: $ 54.00
$ java MovieTheater
Adult tickets: 0
Child tickets: 5
Matinee (y,n): yes
Ticket price: $ 35.00
$ java MovieTheater
Adult tickets: -4
Invalid value
Related Book For
Posted Date: