Uploaded by Ebaadiyan

Ch 4 Program 1 - CinemaPrice

advertisement
CSC110AA and CIS163AA
Ch 4 Program 1 – CinemaPrice
Please adhere to the Standards for Programming Assignments and the Java Code and Style Guidelines.
Submit the following :
•
•
List of source code with comments to document
Test output listed as comments at the end of your program
1. CinemaPrice (10 pts). Design and implement an application called CinemaPrice to determine how much a
person pays to go the cinema. The program should generate an age from 1 - 100 using the Random class and
prompt the user for the full ticket price. Then display the appropriate ticket price using the currency format from
the NumberFormat class (an example in your book ). You may want to refer to the example we did together in
class to help you with the "if statement". Decide ticket price on the following basis:
1.
2.
3.
4.
under 5, free;
aged 5 to 12, half price;
aged 13 to 54, full price;
aged 55, or over, free.
Listed below are several different example outputs. Of course, since the age is being generated
randomly, your example will be different. Just include one example. I have highlighted the currency
format. (your output will not be highlighted)
Please enter the cinema ticket price: 12.50
Your age : 1
Your ticket price is $0.00 which is free.
Please enter the cinema ticket price: 14.75
Your age : 47
Your ticket price is $14.75 which is full price.
Download