Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an application class named GroceryCart.java: 1. Ask the user to enter how many items are they planning to buy today. Save this number as

Create an application class named GroceryCart.java: 1. Ask the user to enter how many items are they planning to buy today. Save this number as an int variable numItems 2. Create two arrays: String [] names and Double [] prices of size numItems 3. Now, using a loop, ask the user to enter the name and price of i-th item in the cart and store them at appropriate locations in the arrays 4. Once the arrays have been create, create two objects of the generic class AnyArray: a. AnyArray nameList = new AnyArray(names); b. AnyArray priceList = new AnyArray(prices); 5. Print the information about nameList and priceList using the toString methods 6. Now, ask the user to enter the name of the item they want to search for and store it in a string variable search. Pass this search item to the method findLocation using the nameList. 7. If the item is found in the list, print its price using the getIth( ) method with priceList. If the item is not found, print Item not found

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

5-23. For living, I require money.

Answered: 1 week ago