Fruit Basket Estimation A famous fruit stall in the marketplace approaches you to create an application...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Fruit Basket Estimation A famous fruit stall in the marketplace approaches you to create an application in which their customers can estimate the total bill amount for the fruits in the basket. As a Java developer, create a Java application to add fruits to the basket and calculate the bill amount. You are provided with a code template which includes the following classes: Fruit Basket class which includes the attributes fruitName, weightinKgs and pricePerkg with all getters and setters, an empty constructor and a three argument constructor which is used to set values to all attributes. FruitBasketUtility class which includes the attribute fruitBasketList with its getter and setter, public void addToBasket (Fruit Basket fbObj) method declaration and public int calculateBill(Stream<Fruit Basket> fruitBasketStream) method declaration. Main class with a main method having user interface for getting the required inputs and pass them as an object to the addToBasket method. Functional Requirements: 1. Enclose your code in the addToBasket method of the Fruit BasketUtility class to add the Fruit Basket object into the fruitBasketList. 2. Enclose your code in the calculateBill method to calculate the total bill amount from the Stream of Fruit Basket objects. Each object will have a fruit detail. On multiplying the weightInKgs and pricePerkg of each Fruit Basket object, the individual bill amount for that particular fruit can be calculated. This method should return the total bill amount by adding each individual bill amount of fruits present in the Stream. 3. Enclose your code in the Main class for retrieving the list of Fruit Basket object from the Fruit BasketUtility class and convert the List of objects into Stream of objects. Then pass the Stream of Fruit Basket objects to the calculateBill method in Fruit BasketUtility class and display the total bill amount. User Interface: Display the options to choose as "Select an option: 1. Add Fruit to Basket 2. Calculate Bill 3.Exit" for all iterations. Any valid option can be chosen as 1 or 2 or 3. Otherwise, display a message as "Invalid option. Please try again." and continue to display the options. For option 1: get the fruitName, weightinKgs and pricePerkg as inputs to process the functional requirements and continue to display the options. For option 2: retrieve the list as mentioned in the functional requirements. If the retrieved list is empty, then display "Your basket is empty. Please add fruits." and continue to display the options. Otherwise, display the total bill amount as "The estimated bill amount is Rs <total bill amount>" and continue to display the options. Note: For option 3: display a message "Thank you for using the application" and terminate. Few of the User Interface requirements will be provided in the code template itself. Adhere to the code template. Enclose your code in the respective required blocks alone. Do not edit or delete the codes provided in the code template. Adhere to the Sample Inputs/Outputs. In the Sample Inputs/Outputs provided, the highlighted text in bold corresponds to the input given by the user and the rest of the text represents the output. Sample Input/Output 1: Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 Your basket is empty. Please add fruits. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Mango Enter weight in Kgs 5 Enter price per Kg 30 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 The estimated bill amount is Rs 150 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Apple Enter weight in Kgs 2 Enter price per Kg 80 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Kiwi Enter weight in Kgs 3 Enter price per Kg 45 Select an option: 2.Calculate Bill 3.Exit 2 The estimated bill amount is Rs 445 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 3 Thank you for using the application. Sample Input/Output 2: Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 4 Invalid option. Please try again. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 Your basket is empty. Please add fruits. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 3 Thank you for using the application. Fruit Basket Estimation A famous fruit stall in the marketplace approaches you to create an application in which their customers can estimate the total bill amount for the fruits in the basket. As a Java developer, create a Java application to add fruits to the basket and calculate the bill amount. You are provided with a code template which includes the following classes: Fruit Basket class which includes the attributes fruitName, weightinKgs and pricePerkg with all getters and setters, an empty constructor and a three argument constructor which is used to set values to all attributes. FruitBasketUtility class which includes the attribute fruitBasketList with its getter and setter, public void addToBasket (Fruit Basket fbObj) method declaration and public int calculateBill(Stream<Fruit Basket> fruitBasketStream) method declaration. Main class with a main method having user interface for getting the required inputs and pass them as an object to the addToBasket method. Functional Requirements: 1. Enclose your code in the addToBasket method of the Fruit BasketUtility class to add the Fruit Basket object into the fruitBasketList. 2. Enclose your code in the calculateBill method to calculate the total bill amount from the Stream of Fruit Basket objects. Each object will have a fruit detail. On multiplying the weightInKgs and pricePerkg of each Fruit Basket object, the individual bill amount for that particular fruit can be calculated. This method should return the total bill amount by adding each individual bill amount of fruits present in the Stream. 3. Enclose your code in the Main class for retrieving the list of Fruit Basket object from the Fruit BasketUtility class and convert the List of objects into Stream of objects. Then pass the Stream of Fruit Basket objects to the calculateBill method in Fruit BasketUtility class and display the total bill amount. User Interface: Display the options to choose as "Select an option: 1. Add Fruit to Basket 2. Calculate Bill 3.Exit" for all iterations. Any valid option can be chosen as 1 or 2 or 3. Otherwise, display a message as "Invalid option. Please try again." and continue to display the options. For option 1: get the fruitName, weightinKgs and pricePerkg as inputs to process the functional requirements and continue to display the options. For option 2: retrieve the list as mentioned in the functional requirements. If the retrieved list is empty, then display "Your basket is empty. Please add fruits." and continue to display the options. Otherwise, display the total bill amount as "The estimated bill amount is Rs <total bill amount>" and continue to display the options. Note: For option 3: display a message "Thank you for using the application" and terminate. Few of the User Interface requirements will be provided in the code template itself. Adhere to the code template. Enclose your code in the respective required blocks alone. Do not edit or delete the codes provided in the code template. Adhere to the Sample Inputs/Outputs. In the Sample Inputs/Outputs provided, the highlighted text in bold corresponds to the input given by the user and the rest of the text represents the output. Sample Input/Output 1: Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 Your basket is empty. Please add fruits. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Mango Enter weight in Kgs 5 Enter price per Kg 30 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 The estimated bill amount is Rs 150 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Apple Enter weight in Kgs 2 Enter price per Kg 80 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 1 Enter the fruit name Kiwi Enter weight in Kgs 3 Enter price per Kg 45 Select an option: 2.Calculate Bill 3.Exit 2 The estimated bill amount is Rs 445 Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 3 Thank you for using the application. Sample Input/Output 2: Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 4 Invalid option. Please try again. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 2 Your basket is empty. Please add fruits. Select an option: 1.Add Fruit to Basket 2.Calculate Bill 3.Exit 3 Thank you for using the application.
Expert Answer:
Answer rating: 100% (QA)
java import javautilArrayList import javautilList import javautilScanner import javautilstreamStream class FruitBasket private String fruitName privat... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Use the data set in Appendix B. Assume that each sample is a simple random sample obtained from a population with a normal distribution. Table Data Set 30 Refer to Data Set 30 Queues in Appendix B....
-
The table below shows the instruction type breakdown of a given application executed on 1, 2, 4, or 8 processors. Using this data, you will be exploring the speedup of applications on parallel...
-
For problems involving composite bodies composed of two or more materials, the elasticity solution requires both boundary conditions and interface conditions between each material system. The...
-
Locate the audited annual financial statements (including the accompanying notes) of Maple Leaf Foods Inc. (Maple Leaf) for its year ended REAL WORLDDecember 31, 2014 (www.sedar.com). Instructions...
-
Two spaceships float in space and are at rest relative to each other. They are connected by a string (see Figure). The string is strong, but it cannot withstand an arbitrary amount of stretching. At...
-
Which feature best describes a PERT chart? a. It creates a time line of production tasks. b. It creates a work flow for production equipment. c. It identifies the critical path of tasks in a project....
-
Charlene and Alton Dutro had lived in their home for two and one-half years when they decided to enlarge and remodel the house. However, their architect advised them that more stringent building and...
-
Take me to the text An employee had $21,800 in gross earnings up to March 20, 2021. She has the following information for her pay for the week ending March 27, 2021. Her employer contributes 100%...
-
What are the factors upon which favorability of transport of a charged solute across the membrane depends?
-
(a) The circuit below operates in steady-state and in CCM. Calculate Vo corresponding to duty ratio of 0.5. 12 V AF 20 A(T) 5 V (b) The circuit below operates in steady-state and in CCM. Calculate Vo...
-
For the one-parameter family of differential equations, with parameter a: dy/dt = e^(-y^(2))+ay-(1/2) Draw a bifurcation diagram, identify the bifurcation values of a, and describe the bifurcations...
-
1. Describe two positive outcomes of decision-making for an organization. 2. Give an example of a nonprogrammed decision. Please be specific. 3. Describe two methods an organization may use to break...
-
A wire carries a current of 0.83 A. This wire makes an angle of 68 with respect to a magnetic field of magnitude 4.5 x 10-5 T. The wire experiences a magnetic force of magnitude 9.8 x 105 N. What is...
-
You just won a lottery that promises to pay you $1 million exactly ten years from today. Because the $1 million payment is guaranteed by the state in which you live, opportunities exist to sell the...
-
What amount of deferred tax assets or deferred tax liabilities are on the two most recent years on the balance sheet? What gives rise to these deferred taxes? What information is disclosed in the...
-
Compile data on consumption and expenditures for the following categories in 30 different countries: (1) food and beverages, (2) clothing and footwear, (3) housing and home operations, (4) household...
-
Which of the following If clauses will evaluate to True when the Bonus check box is selected? a. If chkBonus.Check = True Then b. If chkBonus.Checked Then c. If chkBonus.Checked = True Then d. Both b...
-
In this exercise, you create an application that calculates the number of single rolls of wallpaper required to cover a room. Create a Windows Forms application. Use the following names for the...
-
Which of the following For clauses indicates that the loop instructions should be processed as long as the intX variables value is less than 100? a. For intX As Integer = 10 To 100 b. For intX As...
-
True or False: If the same amount of money is invested in something that can be expensed as in something that must be depreciated (and both provide the same annual returns) then you should choose the...
-
True or False: If investment capital is borrowed, the income tax rate equals \(40 \%\), the after-tax MARR is \(12 \%\), and the loan rate is \(10 \%\), then it is best to repay the loan using Plan 4.
-
The average tax rate on a corporate income of \(\$ 87,000\) is closest to which of the following? a. 15 percent b. 20.5 percent c. 25 percent d. 34 percent
Study smarter with the SolutionInn App