Download AP Computer Science I

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
AP Computer Science I
Java Keyword Lab Assignment # 04
The Pizza Program
100 Point Version
Assignment Purpose:
The purpose of this program is to demonstrate knowledge of calling methods, using
correct parameter passing with some of the common methods found in the Math
class.
Write a program that computes pizza prices. The program should prompt the user to enter the diameter of the
pizza (as an int value, in inches, not as a double) and the price of the pizza (as a double in dollars). Then the
program should compute and display:
1. How many people the pizza feeds, assuming each person gets to eat a minimum 50 in2 of pizza: this
value must be an int, so if your program computes 2.8 people are fed, then the "correct" number of
people it feeds is 2 (with each person getting a bit more than the minimum amount of pizza).
2. The relative price of the pizza (in cents/in2).
3. The cost (in dollars per person, including a 15% tip).
Use the Java math methods in your calculations.
Here are two entire interactions.
Pizza Pricer
Enter diameter of pizza (inches): 12
Enter cost of pizza (dollars)
: 8.50
This pizza feeds 2 people
cents/square inch = 7.515650090450613
cost/person
= 4.887499999999999 dollars (including a 15% tip)
Pizza Pricer
Enter diameter of pizza (inches): 15
Enter cost of pizza (dollars)
: 12.00
This pizza feeds 3 people
cents/square inch = 6.790610905254201
cost/person
= 4.6 dollars (including a 15% tip)
Related documents