Write a C++ program that implements the following class hierarchy. Bill Electicity Bill Where there exists a relation of inheritance between Bill and Electricity Bill. Class Bill should have following members Data member I/for reference number Member functions //to take input of the data members; should be virtual Input () /to display data members of its respective; should be virtual Display () Class Elestcisity.Bill should have following members Data members Units //for units /for per unit price //for tax Тах Member functions /to calculate total amount to be paid after deducting tax amount /to take input of the data members of its respective and former class in the hierarchy //; should be virtual Inputi) //to display data members of its respective and former class in the //hierarchy. This function will call Totalamswoti) and also display the Total amount of I/bill; should be virtual Displayl) Total amount of Bill is calculated as (PatHais.Rrise*Units) - Tax

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.2: Providing Class Conversion Capabilities
Problem 6E
icon
Related questions
Question
Write a C++ program that implements the following class hierarchy.
Bill
Elecuicity Bill
where there exists a relation of inheritance between Bill and Electricity Bill.
Class Bill should have following members
Data member
Bateceose.Oum
/for reference number
Member functions
//to take input of the data members; should be virtual
Input ()
//to display data members of its respective; should be virtual
Display ()
Class Elestricity.Bil should have following members
Data members
/for units
//for per unit price
//for tax
Units
Tax
Member functions
//to calculate total amount to be paid after deducting tax amount
//to take input of the data members of its respective and former class in the hierarchy /I;
should be virtual
Input()
//to display data members of its respective and former class in the
//hierarchy. This function will call Tatalanswoti) and also display the Total amount of //bill.; should be
virtual
Displayl)
Total amount of Bill is calculated as
(PatHnit.Riss Units) - Tax
Transcribed Image Text:Write a C++ program that implements the following class hierarchy. Bill Elecuicity Bill where there exists a relation of inheritance between Bill and Electricity Bill. Class Bill should have following members Data member Bateceose.Oum /for reference number Member functions //to take input of the data members; should be virtual Input () //to display data members of its respective; should be virtual Display () Class Elestricity.Bil should have following members Data members /for units //for per unit price //for tax Units Tax Member functions //to calculate total amount to be paid after deducting tax amount //to take input of the data members of its respective and former class in the hierarchy /I; should be virtual Input() //to display data members of its respective and former class in the //hierarchy. This function will call Tatalanswoti) and also display the Total amount of //bill.; should be virtual Displayl) Total amount of Bill is calculated as (PatHnit.Riss Units) - Tax
You are required to call the display function and hence display the Electricity Bill information
polymorphically (through base class object). The information to be displayed by the display function of
Electricity Bill includes reference number, units, per unit price, tax and total bill amount to be paid.
Output
Please enter reference number 346
Please enter units consumed 20
Please enter per unit price 2
Please enter tax amount
10
Reference number
346
Units
20
Таx
10
Per unit price
Amount to be paid
2
30
Transcribed Image Text:You are required to call the display function and hence display the Electricity Bill information polymorphically (through base class object). The information to be displayed by the display function of Electricity Bill includes reference number, units, per unit price, tax and total bill amount to be paid. Output Please enter reference number 346 Please enter units consumed 20 Please enter per unit price 2 Please enter tax amount 10 Reference number 346 Units 20 Таx 10 Per unit price Amount to be paid 2 30
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
ADT and Class
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning