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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

java

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.
Transcribed Image 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.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Program on Numbers
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT