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 numItems: 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 addltem 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 bl from class Bill with ID 555. • Add the following Item to b1. Item Name Item Price 5.9 Chocolate Rice 12.4 Orange Juice 3.6 Banana 6.3 • Ask the user to enter Item name then search if it's in the list and print its price.
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 numItems: 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 addltem 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 bl from class Bill with ID 555. • Add the following Item to b1. Item Name Item Price 5.9 Chocolate Rice 12.4 Orange Juice 3.6 Banana 6.3 • Ask the user to enter Item name then search if it's in the list and print its price.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 2CP
Related questions
Question
java
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT