2. Write a Java program that computes the size of a pizza and determines its price...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
java public class Pizza public static final double PI 314159265 public static void mainString args double diameter 12 inches double price 699 dollars ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Question 1) The following balances are from the accounts of Tappan Parts: Direct materials inventory Work-in-process inventory Finished goods inventory January 1 (Beginning) December 31 (Ending)...
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Consider the problem of minimizing (x, y) = x subject to g(x, y) = (x 1) 3 y 2 = 0. (a) Show, without using calculus, that the minimum occurs at P = (1, 0). (b) Show that the Lagrange condition P =...
-
5-Androstene-3,17-dione is isomerized to 4-androstene-3,17-dione by hydroxide ion. Propose a mechanism for this reaction. HaC - H20 5-androstene-3,17-dione 4-androstene-3,17-dione
-
QUESTION TWO What are outliers in statistics? (2 Marks) The table below gives a summary of the weights (kg) of members in a sports club. Weight 70-79 80-89 90-99 100-109 110-119 120 - 129 Frequency 9...
-
Which method of evaluating capital investment proposals reduces their expected future net cash flows to present values and compares the total present values to the amount of the investment?
-
Following are the budgeted income statements for the second quarter of 2010 for Marine Tech, Inc.: The company expects about 40% of sales to be cash transactions. Of sales on account, 65% are...
-
1. Record each transaction in July 2. post each transaction to the appropriate T accounts and calculate the ending balance of each account 3. prepare a trial balance s Tony and Suzie graduate from...
-
A teacher recorded the amount of time taken by 21 students to complete a sprint race, to the nearest second, as follows: Two students: between 51 and less than 56 seconds Seven students: between 56...
-
1. Suppose a perfectly competitive firm has a cost function described by TC = 200Q + Q 2 + 225 Each firms marginal revenue is $240. a. Find the profit maximizing level of output. b. Is this a...
-
Triangle company has acquired a controlling interest in Golden Company. After a thorough study, Triangle Company noted that the Golden Company was too conservatively managed and had thought that with...
-
Suppose f(x)=54x - 10, f'(-1) = 30, and f(-1) = 13. Then f(x)
-
James is working on his expense reports and realizes he can probably get away with submitting the expenses for a personal dinner he had with a friend during his recent trip. As he contemplates...
-
Please use current tax rates, exemptions, and laws. Be sure to show ALL of your work so that I can give you partial credit. Use 2 0 2 3 tax law. Use these instructions: 2 0 2 3 Instruction 1 0 4 0 (...
-
If f(x) = 2x-6x+2, find f'(1). f'(1) = (Simplify your answer.).
-
The Problems of Multitasking An eastern U.S. financial services company found itself way behind schedule and over budget on an important strategic program. Both the budget and schedule baselines had...
-
In order to get an idea on current buying trends, a real estate agent collects data on 10 recent house sales in the area. Specifically, she notes the number of bedrooms in each house as follows: a....
-
What does the Java code Scanner keyboard = new Scanner(System.in); keyboard.useDelimiter("y"); System.out.println("Enter a string."); String a = keyboard.next(); String b = keyboard.next();...
-
Suppose we have a satellite in orbit. To communicate to the satellite, we can send messages composed of two signals: dot and dash. Dot takes 2 microseconds to send, and dash takes 3 microseconds to...
-
Add a method bubbleSort to the class ArraySorter, as given in Listing 7.10, that performs a bubble sort of an array. The bubble sort algorithm examines all adjacent pairs of elements in the array...
-
A set of financial statements: a. Is intended to assist users in evaluating the financial position, profitability, and future prospects of an entity. b. Is intended to assist the Internal Revenue...
-
What is the primary characteristic of the form of business organization called the sole proprietorship?
-
What is a business transaction? Give several examples of business transactions and several events that may occur that are not business transactions.
Study smarter with the SolutionInn App