Question: For the Java class PizzaTime that determines best deal with amount of slices, cost per slice or per square inch. public class PizzaTime { public

For the Java class PizzaTime that determines best deal with amount of slices, cost per slice or per square inch.
public class PizzaTime
{
public static void main (String [] args)
{
Pizza app = new Pizza ("Pepperoni",16,10.50,10);
Pizza entree = new Pizza ("Anchovy & Pineapple" ,20,11.95,8);
pizzaPrintStats (appetizer);
System.out.println ();
printPizzaStats (entree);
}
public static void printPizzaStats (Pizza p)
{
System.out.printf ("Your %s pizza has %.2f square inches" +" per slice.
", p.getName(),
p.areaPerSlice();
System.out.printf ("One slice costs $ %.2f, which comes "+" to $%.3f per square inch.
",
p.costPerSlice(),
p.costPerSquareInch());
}
}
Implement the Pizza class with instance var and methods (in java). If the Pizza class were properly defined, here's a sample output below. Use double and printf where appropriate. By comparing the sample output to "new Pizza" constructor calls, you should be able to deduce which numeric arguments in the constructor calls represent number of slices, diameter, and price.
Your Pepperoni pizza has 20.11 square inches per slice
One slice costs $1.05 which comes to $0.052 per square inch.
Your Anchovy & Pineapple pizza has 39.27 square inches per slice.
One slice costs $1.49, which comes out to $0.038 per square inch.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!