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. 1.
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 - (O. 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. 17. Test your program for different values of diameter and price
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
