You are on page 1of 2

04 Prove It 02 Pizza Price

Do you like pizza? Here is a program to help customers judge the price of their pizza at
the Pizza Palace restaurant.

We’ll supply the code, pizza.java, to get you started. Create a new java class called pizza
and copy and paste the pizza.java text that came with these instructions.

Your task is to add code so that your program looks like this:

The Pizza Price Calculator

Answer 1 for Yes or 0 for No for the following extra pizza additions
Pepperoni: 1
Sausage: 0
Ham: 0
Extra Cheese: 1
Pineapple: 0
Onion: 1
Black Olives: 1
Green Peppers: 0
Would you like a Medium Pizza (1=Yes, 0=No): 0
Would you like a Large Pizza (1=Yes, 0=No): 1

Please pay $11.25

Created by Fred Bloggs on 29 July 2013.

Don’t forget to change the name and date at the bottom of the program.

The Pizza Palace charges $5 for a basic pizza, $1 for each additional meat, and $0.50 for
each veggie ingredient. A medium pizza adds 25% and a large adds 50%.

Include the java code where requested by the program comments. Run and test your
program for different Pizza options. You must first calculate the total before testing your
program. So, for the example given above:
Basic pizza price 5
1 extra meat 1
3 extra veggie (3 x 0.5) 1.5 +
------
Sub-total 7.5

Large pizza selected so add on 50% (50/100 = 0.5)


0.5 x 7.5 = 3.75 to add to the sub-total.
Total pizza price = 7.5 + 3.75 = 11.25 (Which matches what the program output)

If your program works correctly, show it to a friend to test.


Extension
Add an extra meat or veggie topping choice to your program (i.e. horse, rabbit, squirrel
etc.)
Add the size option Extra Large which adds an extra 60% to the price.

Submission

1. Copy your program into an email to ROBS@patana.ac.th together with a screen


shot for inspecting the indentation of your code.

Grading Criteria [Total 13 marks]


1 Filename correct
2 Header comment and program comments
1 Good program spacing/formatting
6 All additional meat and veggie options and sizes give correct final price
1 Name and date displayed at bottom
2 1 mark for each extension done

You might also like