Tuesday, February 11, 2020

Class outside Member function




DEPRECIATION UNDER STRAIGHT LINE METHOD

#include<iostream.h>
#include<conio.h>
class depreciation
{
private:
float amt,rate;
float firstdep,secdep,thirddep;
public:
void getdata();
void calculate();
void display();
};
void depreciation::getdata()
{
cout<<"\n\t CALCULATION OF DEPRECIATION UNDER STRAIGHT LINE METHOD";
cout<<"\n\t _________________________________________________________________";
cout<<"\n\t Enter the Value of an Asset:";
cin>>amt;
cout<<"\n\t Enter the Rate of Depreciation:";
cin>>rate;
}
void depreciation::calculate()
{
firstdep=(amt*rate/100);
secdep=(amt*rate/100);
thirddep=(amt*rate/100);
}
void depreciation::display()
{
cout<<"\n\t STATEMENT OF RESULT";
cout<<"\n\t _______________________";
cout<<"\n\n\t Firstdep:"<<firstdep<<"\n\n\t Secdep:"<<secdep<<"\n\n\t Thirddep:"<<thirddep;
}
void main()
{
clrscr();
depreciation d1;
d1.getdata();
d1.calculate();
d1.display();
getch();
}


OUTPUT


CALCULATION OF DEPRECIATION UNDER STRAIGHT LINE METHOD
 _________________________________________________________________

Enter the Value of an Asset: 50000
Enter the Rate of Depreciation: 5

STATEMENT OF RESULT
_______________________

Firstdep: 2500
Secdep: 2500
Thirddep: 2500


No comments:

Post a Comment

Alignment in Excel