Thursday, 20 July 2017

program of class of taxpayer

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class  taxpayer
{
private:
char name[10];
char  pan[20];
float inc;
float tax;
float comptax(float m);


public:
float  totax;
taxpayer(char n[10],float a);
void intax();
void outax();
};

float taxpayer::comptax(float m)
{

if(m<160000)
{
tax=0;
      // cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if((m>160000)&&(m<300000))
{
tax=5;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if((m>300000)&&(m<500000))
{
tax=10;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
else if(m>500000)
{
tax=15;
cout<<"the   tax is "<<tax<<"%\n";
return tax;
}
return 0;
}


taxpayer::taxpayer(char n[10],float a)
{
cout<<"initially  \n ";
strcpy(name,n);
cout<<"\n";
strcpy(pan,"0");
cout<<"\n";
inc=a;
tax=0;
totax=0;
}

void taxpayer::intax()
{
cout<<"enter  your name\n";
gets(name);
cout<<"enter your pan  no\n";
cin>>pan;
cout<<"enter your salary\n";
cin>>inc;
totax=comptax(inc);
}
void taxpayer::outax()
{
cout<<" your name\t";
puts(name);
cout<<" your pan  no\t";
puts(pan);
cout<<"\n";
cout<<" your salary\t"<<inc<<"\n";
cout<<" tax is "<<totax<<"%\n";
}
void main()
{
clrscr();
taxpayer p1("arpit",0);
p1.outax();
p1.intax();
p1.outax();
getch();
}

No comments:

Post a Comment