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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education