Part A Write a class Bill containing the following attribute: V ID: The Bill number of type int V ItemName: array of type String V ItemPrice: array of type double V numltems: the number of items in...


java


Part A<br>Write a class Bill containing the following attribute:<br>V ID: The Bill number of type int<br>V ItemName: array of type String<br>V ItemPrice: array of type double<br>V numltems: the number of items in ItemName and ItemPrice arrays<br>The arrays ItemName and ItemPrice are parallel arrays to store the name and the price of<br>the different items of the bill, respectively.<br>Additionally, the class should include the following public methods:<br>A constructor that takes one parameters of type int to initialize the attribute ID, create<br>ItemName and ItemPrice of size 10 elements and initialize numItems to zero.<br>A method addItem that takes two parameters N of type string and P of type double.<br>The method should add N and P to the ItemName and ItemPrice arrays, respectively<br>and increment numItems (if the arrays are not full).<br>A method getPrice that receive an itemName and return the price of that Item, the<br>method will return -1 if item not found.<br>Part B<br>Write a program that do the following:<br>• Create object b1 from class Bill with ID 555.<br>• Add the following Item to bl.<br>Item Name<br>Item Price<br>Chocolate<br>5.9<br>Rice<br>12.4<br>Orange Juice<br>Banana<br>3.6<br>6.3<br>• Ask the user to enter Item name then search if it's in the list and print its price.<br>

Extracted text: Part A Write a class Bill containing the following attribute: V ID: The Bill number of type int V ItemName: array of type String V ItemPrice: array of type double V numltems: the number of items in ItemName and ItemPrice arrays The arrays ItemName and ItemPrice are parallel arrays to store the name and the price of the different items of the bill, respectively. Additionally, the class should include the following public methods: A constructor that takes one parameters of type int to initialize the attribute ID, create ItemName and ItemPrice of size 10 elements and initialize numItems to zero. A method addItem that takes two parameters N of type string and P of type double. The method should add N and P to the ItemName and ItemPrice arrays, respectively and increment numItems (if the arrays are not full). A method getPrice that receive an itemName and return the price of that Item, the method will return -1 if item not found. Part B Write a program that do the following: • Create object b1 from class Bill with ID 555. • Add the following Item to bl. Item Name Item Price Chocolate 5.9 Rice 12.4 Orange Juice Banana 3.6 6.3 • Ask the user to enter Item name then search if it's in the list and print its price.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here