/** Functions to calculate the area of pizza purchased, given a diameter. * * @author Ian Barland */ class Pizzeria extends Object120 { /** Return the area of a pizza. * @param diam The diameter of the pizza (in inches.) * @return the area of a pizza (in sq.inches.) */ static double pizzaArea( double diam ) { double r; r = diam/2; return Math.PI * r * r; } /** The amount of crust (in sq. in) on a pizza of the given diameter. * Our pizzeria uses 3" crust, all the way around. * @param d the diameter of the pizza. Must be >= 6. * @return The amount of crust (in sq. in) on a pizza of diameter `d`. */ static double crustArea( double d ) { return -99.9; } /** A test driver. */ static void testPizzeria() { System.out.println( "The area of a 20-inch pizza:" ); System.out.println( "Actual: " + pizzaArea(20) ); System.out.println( "Expect: 314 (approx)" ); System.out.println( "" ); System.out.println( "The area of a 0-inch pizza:" ); System.out.println( "Actual: " + pizzaArea(0) ); System.out.println( "Expect: 0" ); System.out.println( "" ); System.out.println( "The area of a 2-inch pizza:" ); System.out.println( "Actual: " + pizzaArea(2) ); System.out.println( "Expect: 3.14 (approx)" ); System.out.println( "" ); System.out.println( "The crust on a 6-inch pizza:" ); System.out.println( "Actual: " + crustArea(6) ); System.out.println( "Expect: ... (approx)" ); System.out.println( "" ); System.out.println( "The crust on a 26-inch pizza:" ); System.out.println( "Actual: " + crustArea(26) ); System.out.println( "Expect: ... (approx)" ); System.out.println( "" ); System.out.println( "The crust on a 14-inch pizza:" ); System.out.println( "Actual: " + crustArea(14) ); System.out.println( "Expect: ... (approx)" ); System.out.println( "" ); System.out.println( "Buffet price for 1 person:" ); System.out.println( "Actual answer: " + buffetPrice(1) ); System.out.println( "Expect answer: 8.00" ); System.out.println( "Buffet price for 2 people:" ); System.out.println( "Actual answer: " + buffetPrice(2) ); System.out.println( "Expect answer: 12.50" ); System.out.println( "Buffet price for 11 people:" ); System.out.println( "Actual answer: " + buffetPrice(11) ); System.out.println( "Expect answer: 53.00" ); System.out.println( "========" ); } static double buffetPrice( int numCusts ) { return 8 + (numCusts-1)*4.5; } }