Question: 2. Write a Java program that computes the size of a pizza and determines its price per square inch, given its diameter and price.

2. Write a Java program that computes the size of a pizza 

2. Write a Java program that computes the size of a pizza and determines its price per square inch, given its diameter and price. 1. Declare a class named constant (PI) for ]-3.14159265. 2. Declare variables for diameter, price, size and price per square inch. Use the naming conventions discussed in class. 3. Initialize the diameter and price with some particular values (like 12 and 6.99) 4. For finding the size of the pizza use the formula: size - (diameter) / 4 5. For finding the price per square inch use the formula: price_sq_inch - price / size 6. Show the output in the following format: The size of the pizza with a diameter of xx inches. is xx.xx square inches. The price per square inch for the same pizza is $xx.xx. 7. Test your program for different values of diameter and price.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

java public class Pizza public static final double PI 314159265 public static void mainString args double diameter 12 inches double price 699 dollars ... View full answer

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!