Thursday, February 20, 2020

C++ Program - using class function inside the class


 DEPRECIATION UNDER DIMINISHING BALANCE METHOD
#include<iostream.h>
#include<conio.h>
class depreciation
{
float amount,rate,bal1,bal2,bal3;
floatfdep,secdep,thirddep;
public:
voidgetdata()
{
cout<<"\n\n\t\t CALCULATION OF DEPRECIATION UNDER DIMINISHING BALANCE METHOD";
cout<<"\n\n\t\t_______________________________________________________________";
cout<<"\n\n\t Enter the value of assets:";
cin>>amount;
cout<<"\n\n\t\t Enter the rate of depreciation:";
cin>>rate;
}
void calculate()
{
fdep=(amount*rate/100);
bal1=(amount-fdep);
secdep=(bal1*rate/100);
bal2=(bal1-secdep);
thirddep=(bal2*rate/100);
bal3=(bal2-thirddep);
}
Void show_result()
{
cout<<"\n\n\t\t RESULT STATEMENT";
cout<<"\n\n\t\t ________________";
cout<<"\n\n\t\t First year Depreciation:"<<fdep;
cout<<"\n\n\t\t First year Balance:"<<bal1;
cout<<"\n\n\t\t Second year Depreciation:"<<secdep;
cout<<"\n\n\t\t Second year Balance:"<<bal2;
cout<<"\n\n\t\t Third year Depreciation:"<<thirddep;
cout<<"\n\n\t\t Third year Balance:"<<bal3;
}
};
void main()
{
clrscr();
depreciation d2;
d2.getdata();
d2.calculate();
d2.show_result();
getch();
}




OUTPUT

CALCULATION OF DEPRECIATION UNDER DIMINISHING BALANCE METHOD _________________________________________________________________________

Enter the value of assets: 100000
Enter the rate of depreciation: 10
RESULT STATEMENT
____________________

First year Depreciation: 10000
First year Balance: 90000
Second year Depreciation: 9000
Second year Balance: 81000
Third year Depreciation: 8100
Third year Balance: 72900


No comments:

Post a Comment

Alignment in Excel