Question: You are required to write a C + + program that processes an Electric _ Bill class through various operations. Please address the following sub

You are required to write a C++ program that processes
an Electric_Bill class through various operations.
Please address the following sub-questions:
1. Create an Electric_BIll class with the following
specifications:
It should have private attributes for the yearly bill, which
is an int array of 6 years data, and another similar array
for reversed bill data.
In main function, define two int arrays:
{230,270,190,560,350,260} and
{150,230,770,590,100,520}.(4 points)
2. Provide a constructor and initialise two objects
(named Comp1 and Comp2) using the two arrays above.
Implement a member function of
class Electric_BIll called show to display the raw
yearly bill data, call this function in the main function to
show the bill data of Comp1 or Comp2.(6 points)
3. Implement two member functions
of Electric_BIll class:
(1) Write a reverse function to reverse the bill data in
Comp1 and call this function from main function. (6
points)
(2) Write two member functions named Max and Min
and return the year index of the maximum and minimum
of Comp2 and call it from the main function (e.g. for
Comp2 should return 3.(6 points)
4. Overload the operator -
in Electric_Bill class to calculate the subtraction
of Comp1 and Comp2, and use Comp1-Comp2 to return
delta (this should be another Electric_Bill object)
and display the bill data of delta in main function. (8
points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!