Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA CODE ONLY! You are a store owner. You want to total the sales for a specific item (ex: all 5 pound bags of apples

JAVA CODE ONLY!

image text in transcribed

image text in transcribed

You are a store owner. You want to total the sales for a specific item (ex: all 5 pound bags of apples sold that week). You will update the program you created in problem 2 and create a new method to do this. Create a new method in the PurchaseTotalDemo called getTotalSales which passes in an array of PurchaseTotal records and the name of the item to search for. The search should not be case-sensitive. It will return a double containing the total sale for all matching items. The totalSale for one item would be itemsSold * itemPrice. Example: Let's say on 10/01/2019, you sold 25 watermelons for $2 each (totalSale=\$50) and on 10/02/2019, you sold 20 watermelons for $2 each (totalSale= $40 ) and on 10/03/2019, you sold 30 watermelons for $2 each (totalSale =$60 ). If you called the getTotalSales method, passing in the PurchaseTotal array and the String "Watermelon", the method would return $150($50+$40+$60). In the main method of the PurchaseTotalDemo, call the getTotalSales method for a specific item from your array (ex: Watermelon), and display the total that gets returned by the method. Class outline: PurchaseTotal a saleld : int a itemName : String a price : double a itemsSold : int a date: String - PurchaseTotal(int, String, double, int, String) getSaleld 0 : int gettemName 0 : String getPrice0: double getlemsSold 0 : int getDate0 : String PurchaseTotalDemo s main(String[]) : void S calculatelnventory(PurchaseTotal[], String, int) : int $ getTotalSales(PurchaseTotal[], String) : double

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

More Books

Students also viewed these Databases questions