Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed 

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

Step: 1

java public class Pizza public static final double PI 314159265 public static void mainString args double diameter 12 inches double price 699 dollars ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

What is the factor rating method, and how does it work?

Answered: 1 week ago