Penguin Shaved Ice

Project Three Page 1
Project 3
Penguin Shaved Ice – Part II
Write a program for a shaved ice stand (aka snowball stand) to display the bill for the
cashier. The program requests the name and zip code of the shaved ice stand and converts
the text. The program then accepts the number of sales per size, performs the necessary
computations, computes the 6% tax, and displays the bill similar to the example below.
You are going to create two classes: IceStand.java and Snowball.java. (Please follow
specifications and do not create any extra methods or properties).
IceStand Class:
This class has two properties: Name and Location (both are strings). Create the
corresponding Mutators (set methods) with this specification:
setName: coverts the shaved ice stand name entered by the user to all capital letters, and
add the extra line (see example below). This value is assigned to the corresponding
property.
setLocation: based on the zip code entered by the user, assign the corresponding location.
21228 Catonsville
21222 Dundalk
21237 Essex
Other value Baltimore
Constructor:
Create only one constructor that accepts the name of the shaved ice stand, and the zip code
entered by the user, and call the corresponding mutators, so the properties can be set up.
toString Method: return a string with the name and location (first three lines of the receipt).
Snowball Class:
This class has the following properties:
String size
Integer quantity
Double unitPrice
Double totalPrice
In addition, it will have a constant: TAX_RATE (this value should be static).
Constructor:
In this case create an empty constructor (all the properties initialized to zero or null).
calculatePrice Method: this method will receive the size, quantity, and unit price of the
snowball sold:
Small $ 1.25
Medium $ 2.40
Large $ 3.55
Project Three Page 2
This method will set the size, quantity, and unit price, and calculate the total price. It
will also return the total price calculated.
toString Method: will return the string composed by the size, quantity, unit price, and total
price. Please format the prices using the currency format.
calculateTax Method: this method will return the value of the tax based on the total sent to
it. This method should be static.
Now, that you have your two classes ready, you can test them by creating the
PenguinShavedIce.java demo:
Prompt the user for the name of the shave ice stand, and the zip code.
Use the IceStand class to set the name and location values.
Prompt the user for the number of small, medium and large snowballs sold in this
transaction (your loop will end when the quantity for small is -1).
Display the title of the receipt.
Use the Snowball class to instantiate three objects smallSnowball, mediumSnowball,
largeSnowball, and calculate the total for each one of them.
Display the detail of the receipt.
Calculate and display the tax for the whole bill.
Calculate and display the total of the bill.
In each iteration of the loop: print the title of the receipt, the detail, the tax, and the total
bill.

Enter name of shaved ice stand: Baltimore Shaved ice
Enter zip code: 21237
Enter number of small (-1 to stop).....8
Enter number of medium......2
Enter number of large.......5
BALTIMORE SHAVED ICE
//////// ~ ~ ~ \\\\\\\\
Essex
Price Total
Small 8 $ 1.25 $ 10.00
Medium 2 $ 2.40 $ 4.80
Large 5 $ 3.55 $ 17.75
Sub-total $ 32.55
Tax (6%) $ 1.95
Total bill $ 34.50
Enter number of small (-1 to stop).....
Grading: PenguinShavedIce.java (20 points)
IceStand.java (15 points)
Snowball.java (15 points)
Testing and Accuracy (5 points)
Powered by