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...
-
Calculate dollar amounts accurate to the cent, and percent amounts accurate to the nearest 0.01%. $100 is 10% less than what amow1t?
-
Explain the different types of static and dynamic stability.
-
Titan Mining Corporation has 9.3 million shares of common stock outstanding and 260,000 6.8 percent semiannual bonds outstanding, par value $1,000 each. The common stock currently sells for $34 per...
-
Examine the role of Global Supply Chains and the related risks and opportunities in context to international business. Can residents live and work at the same place a tourist seeks enrichment,...
-
Housley Paints Co. had a remaining debit balance of $25,000 in its under-and overapplied factory overhead account at year-end. The balance was deemed to be large and, therefore, should be closed to...
-
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...
-
True or False The graph of the exponential function f (x) = a x , where a > 0 and a 1, has no x-intercept.
-
Suppose that just by doubling the amount of output that it produces each year, a firms per-unit production costs fall by 30 percent. This result is an example of: a. economies of scale. b. improved...
-
The Hightown Council refused to increase the town budget. Robert Read was laid off from work on August 4, 2019. Earlier in the year he had been temporarily disabled from a job-related injury and had...
-
The power factor for an inductive circuit ( \(R\) - \(L\) load), in which the current lags the voltage, is said to be (a) Lagging (b) Leading (c) Zero
-
In 1820, living standards in various places around the globe were _______ they are today. a. more widely varying than b. just as widely varying as c. less widely varying than
-
True or False. Countries that currently have a low real GDP per capita are destined to always have lower living standards than countries that currently have a high real GDP per capita.
-
Two particles, A and B, have the same mass, but particle A has a charge of +q and B has a charge of +2q. The particles are accelerated from rest through the same potential difference. Which one has...
-
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}?
-
12. An amusement park ride swings riders around a 25 meter radius circle at a speed of 16 m/s. What is the centripetal acceleration in meters per second-squared felt by each rider? (Answer with 3...
-
For the image matrix given , use the Sobel horizontal edge detector to 1 2 -2 detect horizontal edges. Sobel matrix for horizontal edges is 0 0 104
-
What role does a resource allocation graph play in identifying potential deadlocks, and how can it be utilized to devise strategies for deadlock prevention ?
Study smarter with the SolutionInn App