Assignment
2: Date: 6-9-2003
File name: MovieCashierApplet.java
File name: MovieCashierApplication.java - SUBMIT
ASSIGNMENT HERE
Type:
Applet & Application Due
Description:
Blockbuster Incorportated has recently hired you to create an application
and an applet (to post on their web site) to calculate the costs of
going to the Movies as opposed to staying home with a rental movie
(Your program will only calculate the cost of going to the Movies).
Ticket prices are as follows:
Adult Ticket
Price is $8.75
Child Ticket Price is $5.50
In addition
to calculating the cost of tickets, you must also add California Sales
Tax to the price and calculate the cost for tickets with a 10% student
discount. Sales tax and the rate of discount (10%) should be declared
as constant double values. Your program is expected to ask the user
for their movie selection, then ask the user for the quantity of Adult
tickets, then the quantity of Child tickets. Once the user has entered
both, your program will output the total price and the discounted
price of the tickets.
Minimum
data specification requirements:
1) Use good naming scheme for all of your variables for readability.
2) Use a double variable named TAX_RATE and assign the value
of .0775 (7.75% - cal sales tax)
3) Use a double variable named STUDENT_DISCOUNT and assign
the value of .10 (10%)
4) Use float data type for all variables used for monetary values
(This will pose some challenges for you to cast your data to the
correct
type in calculation, especially in the applet where input is taken
from JOptionPane).
5) Display of monetary values
is limited to two decimal places. So, a number like 23.6890
should be displayed as $23.69.
6) Use JOptionPane.showInputDialog for retrieving information with
the applet and JOptionPane.showMessageDialog to display messages.
The application will use EasyIn class.
6) Programs should prompt
the user to select one of the following movies:
1) Martin Lawrence Live: Runteldat
(R)
2) The Last Kiss (R)
3) The Crocodile Hunter: Collision Course (PG-13)
4) Lilo & Stitch (PG)
5) Happy Times (PG)
6) Austin Powers in Goldmember (PG-13)
7) The Kid Stays in the Picture (R)
8) The Country Bears (G)
9) Full Frontal (R)
Prerequisite:
The lecture on "Basic Data Type" should precede this assignment.
Hint:
1) The formula to calculate the total price with sales tax is ((price
* TAX_RATE) + price).
2) The formula to calculate the discounted price is (totalPrice
- (totalPrice * STUDENT_DISCOUNT)).
Since all monetary values are stored in floats and percentage are
stored in doubles, type casting will be needed.
3) You should use the EasyIn package
for input in text mode application as shown in class. NOTE:
Do NOT insert the source code for EasyIn inside your program, right
click on the link and download it into the same directory of your
homework, compile it and you should be able to used it as described
in the file comments. No import statement needed to use EasyIn.
Notes:
Since we have not cover any conditional statement (if / else), I will
not check this program for "crash-proof" quality. It will
be assumed that the user will type correct data for ticket quantities.
5
Objectives:
* Understand data type, arithmetic precedence and perform basic calculation
as well as data type casting.
* Be familiar with the development environment.
* Be able to create, edit, compile, run a Java applet from an embedded
HTML file.
* Be able to create, edit, compile, run a Java application from the
command line console.
* Be able to follow the predefined formatting standards from the instructor.
Sample
Application Execution:
>java
-cp . MovieCashier
Hello! Welcome to the Movie Cashier
The current movies playing are:
1) Martin Lawrence Live: Runteldat (R)
2) The Last Kiss (R)
3) The Crocodile Hunter: Collision Course (PG-13)
4) Lilo & Stitch (PG)
5) Happy Times (PG)
6) Austin Powers in Goldmember (PG-13)
7) The Kid Stays in the Picture (R)
8) The Country Bears (G)
9) Full Frontal (R)
Please select a movie
>1
How many adult tickets would you like to purchase for movie 1?
>4
How many childern tickets would you like to purchase for movie
1?
>2
The total cost for your movie tickets are $49.56
Price with student discount $44.61 |
Sample
Applet Execution




