Computer Science, asked by Pavan70221, 10 months ago

Define a class Ele_Bill in C++ with the following descriptions: Private members:
Cname of type character array
Pnumber of type long
No_of_units of type integer
Amount of type float.
Calc_Amount( ) This member function should calculate the amount as No_of_units*Cost . Amount can be calculated according to the following conditions:
No of units Cost
First 50 units Free
Next 100 units 0.80 @ unit
Next 200 units 1.00 @ unit
Remaining units 1.20 @ unit Public members:
* A function Accept( ) which allows user to enter Cname, Pnumber, No_of_units and invoke function Calc_Amount().
* A function Display( ) to display the values of all the data members on the screen.

Answers

Answered by 01DEVKARDAM10
3

Answer:

Explanation:

class Ele_Bill

{

char cname;

long pnumber;

Int No_of_ units;

float Amount, cost;

Void Calamount

{

if(No_of_units<=50)

{cost=o;

return(No_of_units*cost)

}

if(50<No_of_units&&No_of_units=>100)

{cost=0.80;

return (No_of_units*cost)

}

If(100<No_of_units&&No_of_units>=1)

{Cost=1;

return(No_of_units*cost)

}

Else

{Cost=1.2

Return (No_of_units*cost)

}

}

public:

void Accept()

{

Cout<<"cname";

gets(cname);

Cout<<"pnumber";

Cin>>pnumber;

Cin>>No_of_units;

Amount=Calamount ();

}

void display ()

{

Cout>>cname;

cout>>pnumber;

Cout>>No_of_units;

Cout>>amount;

}

};

It's your answer

#DEV

Answered by raghuvarandamodaran2
0

Explanation:

class Ele_Bill

{ char Cname[20];

long Pnumber;

int No_of_units;

float Amount;

void Calc_Amount( );

public:

void Accept();

void Display();

};

void Ele_Bill : : Calc_Amount( )

{ if(No_of_units<=50) { Amount=0; } else if(No_of_units<=150) { Amount=(No_of_units-50)*0.80; } else if(No_of_units<=350) { Amount=80+(No_of_units-150)*1.00; } else { Amount=80+200+(No_of_units-350)*1.20; } } void Ele_Bill :: Accept( ) { gets(Cname); cin>Pnumber>>No_of_units; Calc_Amount( ); } void Ele_Bill :: Display( ) { cout<

Similar questions