C++ programme to compute tax of a person using a class taxpayer. Class taxpayer should the person's details of account including PAN no

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class taxpayer{
                                                            int pan;
                                                            char name[20];
                                                            long float tableinc;
                                                            double tax;
                                                            public:
                                                            void inputdata();
                                                            void display();
                                                            double computetax();
                                                            };
void taxpayer::inputdata()
               {
               cout<<"enterpersonal acct num:";
               cin>>pan;
               cout<<"\nenter the name of the person:";
               gets(name);
               cout<<"\nenter total annual taxable income:";
               cin>>tableinc;
               }
double taxpayer::computetax()
               {
               if(tableinc<=60000)
                              tax=0;
               else if((tableinc>60000)||(tableinc<=150000))
                              tax= tableinc *0.05;
               else if(tableinc>150000||tableinc<=500000)
                              tax=tableinc*0.1;
               else
                              tax=tableinc*0.15;
               return (tax);
               }

void taxpayer::display()
               {
               cout<<"\npan num:"<<pan<<"\tname:";
               puts(name);cout<<"\ttotal annual income:"<<tableinc<<"\tTax payable:"<<tax;
               }
void main()
{
clrscr();
taxpayer a;
a.inputdata();
clrscr();
a.computetax();
a.display();
getch();
}

OUTPUT:


Enter personal acct num:121

enter the name of the ethiopian:ARUN

enter total annual taxable income:120000

pan num:121     name:ARUN
               total annual income:120000      Tax payable:6000

No comments:

Post a Comment