Saturday, 23 March 2019

CPP-EX57

Consider the following class Person
                 Class Person
                {
                               char Name [20];
            char Addr [30];
            float Salary;
             int Property;    //in sq. foot area
            float tax_amount;
                           Public:
                           // methods
                 };
    Calculate tax amount by checking salary and the property of the person
         For salary <5000 
              tax rate=0
                        For salary >=5000||<=10000
             tax rate= 14% of salary.
                        For salary >=10000   
                           tax rate =16% of salary.

    In this tax amount add following amt depending
 on the size of area in sq.foot
                     For 1000 sq. foot area
            amt=0.
                     For >1000|| < 5000 sq.
 foot area     amt= 1000
                     For >5000||<= 10000 sq.
 foot area     amt=3000.*/

#include <iostream.h>
#include <conio.h>
class Person
{
    char Name [20];
    char Address [30];
    float Salary;
    int Property;    //in sq. foot area
    float tax_amount;
    double tax_amount1;
    public:
    // methods

        void get()
        {

            cout<<"\n\nEnter Name :-";
            cin>>Name;

            cout<<"\n\nEnter Address :-";
            cin>>Address;

            cout<<"\n\nEnter Salary:-";
            cin>>Salary;

            cout<<"\n\nEnter Property in sq. foot area :-";
            cin>>Property;
        }

        float get_saltax(float Salary)
        {
            tax_amount=0;
            if(Salary <5000)
                tax_amount=0;
            else if(Salary >=5000|| Salary<=10000)
                tax_amount=Salary*0.14;
            else if(Salary >=10000)
                tax_amount=Salary*0.16;

            return tax_amount;
        }

        double get_areatax(int Property)
        {
            tax_amount1=0;
            if(Property<1000)
                tax_amount1=0;
            else if(Property >=1000|| Property <5000)
                tax_amount1=Property*1000/100;
            else if(Property>5000||Property<= 10000)
                tax_amount1=Property*3000/100;

            return tax_amount1;
        }

        void display()
        {

            cout<<"\nName:-\t"<<Name;
            cout<<"\nAddress:-\t"<<Address;
            cout<<"\nYour salary is :\t"<<Salary;
            cout<<"\nYour salary paid tax is :\t"<<get_saltax(Salary);
            cout<<"\nYour property (size of area in sq.foot) is :\t"<<Property;
            cout<<"\nYour property paid tax is :\t"<<get_areatax(Property);

        }
};


void main()
{
    Person p1;
    clrscr();
    cout<<"Following is tax details as per you provided information\n";
    p1.get();
    p1.display();
    getch();
}