google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Saturday, February 21, 2015

C++ Program to find tax of person salary

Consider the following class person
class person
{
char name[20];
char addr[30];
float salary;
int property;
float tax;
public:\\method
};
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 sqr.foot
for 100 sqr.foot        amt=0
for>1000||<5000            amt=1000
for>5000||<=10000        amt=3000


#include<conio.h>
#include<iostream.h>
class person
{
char name[20],addr[30];
float sal,tax_amt;
int prop;
public:void accept();
       void display();
};
void person::accept()
{
cout<<"\n Enter the name:-";
cin>>name;
cout<<"\n Enter address:-";
cin>>addr;
cout<<"\n Enter salary:-";
cin>>sal;
cout<<"\n Enter how much Rs. of property you have:-";
cin>>prop;
tax_amt=0;
if(sal<5000)
tax_amt=tax_amt+0;
if(sal>=5000&&sal<=10000)
tax_amt=tax_amt+(sal*0.14);
if(sal>=10000)
tax_amt=tax_amt+(sal*0.16);
if(prop==1000)
tax_amt=tax_amt+0;
if(prop>1000&&prop<5000)
tax_amt=tax_amt+1000;
if(prop>5000&&prop<=10000)
tax_amt=tax_amt+3000;
}
void person::display()
{
cout<<"\n Name:-"<<name;
cout<<"\n Address:-"<<addr;
cout<<"\n Salary:-"<<sal;
cout<<"\n Property:-"<<prop;
cout<<"\n Tax Amount:-"<<tax_amt;
}
int main()
{
person p;
clrscr();
p.accept();
p.display();
getch();
return 0;
}

=====================================================
OUTPUT :  -
Enter the name:-ABC
Enter address:-XYZ
Enter salary:-5000
Enter how much Rs. of property you have:-10000

Name:-ABC
Address:-XYZ
Salary:-5000
Property:-10000
Tax Amount:-3700

C++ program for medical shoppee

Create a class medical shoppe containing
-medicine
-qty
-price
medicine details are stored into file medical.txt. when any medicine
has to be sold it is first searched into file. if found the quantity
is decremented that much quantity to be sold.

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<iomanip.h>
#include<stdlib.h>
#include<stdio.h>
class medical
{
public:char med[20];
       int qty,price;
public:void accept()
       {
       cout<<"\nenter the medicine name:-";
       cin>>med;
       cout<<"\nenter qty:-";
       cin>>qty;
       cout<<"enter price";
       cin>>price;
       }
       void display()
       {
       cout<<"\nmedicine name:-"<<med;
       flushall();
       cout<<"\nquantity:-"<<qty;
       cout<<"\nprice:-"<<price;
       }
       void search(char n[20],int q)
       {
       int ans=1;
       ans=strcmp(med,n);
       if (ans==0)
       qty=qty-q;
       }

};
int main()
{
medical m[3];
int i,q,ans;
char n[20];
clrscr();
fstream f1;
f1.open("a.doc",ios::trunc|ios::in|ios::out);
cout<<"\n\t\tenter the details\n";
for(i=0;i<3;i++)
{
m[i].accept();
f1.write((char *)&m[i],sizeof(m[i]));
}
f1.seekg(0);
cout<<"\nenter the medicine name which is to be sold:-";
cin>>n;
cout<<"\nhow much quantity you want:-";
cin>>q;
for(i=0;i<3;i++)
{
f1.read((char *)&m[i],sizeof(m[i]));
m[i].search(n,q);
f1.write((char *)&m[i],sizeof(m[i]));
}
cout<<"\n\t\tdisplay of all records in a file\n";
for(i=0;i<3;i++)
{
f1.read((char *)&m[i],sizeof(m[i]));
m[i].display();
}

getch();
return 0;
}


--------------------------------------------------------------------
OUTPUT


                enter the details                                              
                                                                               
enter the medicine name:-per                                                   
                                                                               
enter qty:-34                                                                  
enter price56                                                                  
                                                                               
enter the medicine name:-12                                                    
                                                                               
enter qty:-76                                                                  
enter price45                                                                  
                                                                               
enter the medicine name:-df                                                    
                                                                               
enter qty:-34                                                                  
enter price12                                                                  
                                                                               
enter the medicine name which is to be sold:-df                                
                                                                               
how much quantity you want:-12
                                                                               
                display of all records in a file                               
                                                                               
medicine name:-per                                                             
quantity:-34                                                                   
price:-56                                                                      
medicine name:-12                                                              
quantity:-76                                                                   
price:-45                                                                      
medicine name:-df                                                              
quantity:-22
price:-12

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...