CS 157 Spring 2001

Assignment 3 –Calculations

100 points

 

Assigned: 01/31/2002

Due: 02/07/2002 at the start of class

 

Pre-Lab (Do Before Lab):  Bring a new disk. Plan out sequence of statements needed for program.

 

Main Assignment:

Write a program that calculates the price per square inch for pizza from a restaurant. This will require getting 2 pieces of data from the user: the price of the pizza, and the diameter of the pizza (in inches). The task also involves performing calculations and displaying the output. The necessary information is given below.

 

Sample Questions to be asked of the user:

 

Please enter the price of the pizza

 

Please enter the diameter of the pizza (in inches)

 

Sample Results to be Displayed:

 

Results:

      Diameter:           16.0   

Radius:             8.0   

Area:               201.06176

Price:              10.5

 

      Cost Per Sq Inch:   0.052222759812706306

 

Hand in:

 

Miscellaneous:

                Define pi as a constant equal to 3.14159. See class notes, this needs to be declared at the top of the class.

 

Please try to make the output of your program like mine, to aid my grading. (but note that we haven’t done anything yet with specifying how many decimal places to display)

 

You will need the SavitchIn.java file (still obtainable from my WWW page  - or from last week).

 

MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors).

 

Put YOUR NAME, and e-mail address in comments at the beginning of the program.

 

You MUST include comments that explain your program in order to get full credit.