Write a program that uses the Purchase class in Listing 5.13 to set the following prices: Oranges:
Question:
Write a program that uses the Purchase class in Listing 5.13 to set the following prices:
Oranges: 10 for $2.99
Eggs: 12 for $1.69
Apples: 3 for $1.00
Watermelons: $4.39 each
Bagels: 6 for $3.50
Then calculate the cost of each of the following five items and the total bill:
2 dozen oranges
3 dozen eggs
20 apples
2 watermelons
1 dozen bagels
Listing 5.13
Transcribed Image Text:
import java.util.Scanner; /** Class for the purchase of one kind of item, such as 3 oranges. Prices are set supermarket style, such as 5 for $1.25. */ public olass Purchase private String nam private int groupCount; e; //Part of a price, like the 2 in //2 for $1.99. //Part of a price, like the $1.99 // in 2 for $1.99. //Number of items bought. private double groupPrice; private int numberBought; public void setName (String newName) = newName; name /** Sets price to count pieces for $costForCount.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (12 reviews)
public class Purchase private String name private int groupCountPart of price like the ...View the full answer
Answered By
Mugdha Sisodiya
My self Mugdha Sisodiya from Chhattisgarh India. I have completed my Bachelors degree in 2015 and My Master in Commerce degree in 2016. I am having expertise in Management, Cost and Finance Accounts. Further I have completed my Chartered Accountant and working as a Professional.
Since 2012 I am providing home tutions.
3.30+
2+ Reviews
10+ Question Solved
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Question Posted:
Students also viewed these Computer science questions
-
Write a program that uses the finite difference scheme to solve the one-dimensional wave equation Given boundary conditions V(0, i) = 0, V(l, t) = 0, t > 0 and the initial condition ?V/?t (x, 0) = 0,...
-
Write a program that receives an ASCII code (an integer between 0 and 127) and displays its character. For example, if the user enters 97, the program displays the character a. Here is a sample run:...
-
Write a program that simulates stable storage. Use two large fixed-length files on your disk to simulate the two disks.
-
Do you agree or not? Specialization of labor and better use of capital goods can initially generate increasing marginal output (returns) for a firm in the production of a good.
-
Repeat Prob. 10-104 assuming isentropic efficiencies of 100 percent for the pump, 85 percent for the compressor, and 90 percent for the gas and steam turbines. Prob. 10-104 The gas-turbine cycle of a...
-
Choose the correct preposition, or none if none is required. The interview provided insight (about/into/for/none) the creative process of great directors.
-
Consider the multiple linear regression model for the rental price data in Problem 3.42. Problem 3.42 Table B.24 contains data on median family home rental price and other data for 51 US cities. Fit...
-
Tolo Co. plans the following repurchases: $10 million in one year, nothing in two years, and $20 million in three years. After that, it will stop repurchasing and will issue dividends totaling $25...
-
1. Wallace's original single plantwide overhead allocation rate costing system allocated indirect costs to products at $140.00 per machine hour. Compute the total indirect costs allocated to the...
-
The small cart has a speed v A = 4 m /s as it passes point A. It moves without appreciable friction and passes over the top hump of the track. Determine the cart speed as it passes point B. Is...
-
Repeat Exercise 1 for a collection of coins instead of a credit card. Exercise 1 Design a class to represent a credit card. Think about the attributes of a credit card; that is, what data is on the...
-
Write a program to answer questions like the following: Suppose the species Klingon ox has a population of 100 and a growth rate of 15 percent, and it lives in an area of 1500 square miles. How long...
-
A company (which is not a member of a group) has the following results for the 14 months to 31 December 2020: Accrued building society interest was 3,000 on 31 October 2019, 4,000 on 31 October 2020...
-
Name two conditions when a company should increase financial leverage? Also elaborate both of them.
-
Drinking fountains that actively chill the water they serve cant work without ventilation. They usually have louvers on their sides so that air can flow through them. Why do they need this airflow?
-
How did Ptolemys atlas contribute to a greater understanding of world geography, and how did it produce confusion?
-
Arctic Cat sold Seneca Motor Sports a shipment of snowmobiles. The snowmobiles were delivered on January 1, 2024, and Arctic received a note from Seneca indicating that Seneca will pay Arctic $31,800...
-
Riverside Incorporated makes one model of wooden canoe. Partial information for it follows: Number of Canoes Produced and Sold 520 670 820 Total costs Variable costs Fixed costs $ 72,800 148,500 ? ?...
-
The file HotelPrices contains the prices in British pounds of a room at two-star, three-star, and four star hotels in cities around the world in 2012. (Data extracted from bit.ly/Q0qxe4.) Complete...
-
In the synthesis of the keto acid just given, the dicarboxylic acid decarboxylates in a specific way; it gives Explain. HO rather than HO
-
Dr. Amongus claims that the order in which a fixed set of entries is inserted into an AVL tree does not matterthe same AVL tree results every time. Give a small example that proves he is wrong.
-
Dr. Amongus claims that the order in which a fixed set of entries is inserted into a binary search tree does not matterthe same tree results every time. Give a small example that proves he is wrong.
-
How many different binary search trees can store the keys {1,2,3}?
-
Discuss at least five of the formatting decisions you would have to make when typing a table. Compare the decisions you provided to those of two of your classmates. Do you agree or disagree with the...
-
1-2. Draw graphs of the following functions using transformations: 1. y = 2x-1 x-2' 2. y log2x+1|- 3.
-
Assume a simultaneous open market purchase of 100 million from the Bank of England and a repayment of a discount loan of 5 million from Bank A to the Bank of England. Show the overall change in their...
Study smarter with the SolutionInn App