6 Aug 2014

Project based on C++,Civil engineering shop Account manipulation

Basically it is console based application which keeps tracks of good in your inventory,making bills,keeping records of customer and their Account Manipulation.

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>

int q=0;
class customer;
class item
{
public:
char name[15];
float cost;
int quantity,iq;
int sold_out;
int stock;

void getdata(int a)
{
cout<<"1>Cement\n2>Bricks\n3>Steel\n4>Sand\n5>Kapchi\n";
cout<<"Enter name of item:-";
cin>>name;
xyz:
if(a==0)
  {
  cout<<"\nEnter cost of "<<name<<"(per bag):-";
  cin>>cost;
  cout<<"\nEnter quantity of "<<name<<" bought:-";
  cin>>quantity;
  cout<<"\nEnter quantity of "<<name<<" sold out:-";
  cin>>sold_out;
  stock=quantity-sold_out;
  }
else if(a==1)
  {
  cout<<"\nEnter cost of "<<name<<"(per piece):-";
  cin>>cost;
  cout<<"\nEnter quantity of "<<name<<" bought:-";
  cin>>quantity;
  cout<<"\nEnter quantity of "<<name<<" sold out:-";
  cin>>sold_out;
  stock=quantity-sold_out;
  }
else if(a==2)
  {
  cout<<"\nEnter cost of "<<name<<"(per kg):-";
  cin>>cost;
  cout<<"\nEnter quantity of "<<name<<" bought:-";
  cin>>quantity;
  cout<<"\nEnter quantity of "<<name<<" sold out:-";
  cin>>sold_out;
  stock=quantity-sold_out;
  }

else
  {
  cout<<"\nEnter cost of "<<name<<"(per cubicfoot):-";
  cin>>cost;
  cout<<"\nEnter quantity of "<<name<<" bought:-";
  cin>>quantity;
  cout<<"\nEnter quantity of "<<name<<" sold out:-";
  cin>>sold_out;
  stock=quantity-sold_out;
  }
cout<<"\n\nTo lock value press 4 or to re-enter value for same item press 9:-";
int c;
cin>>c;
if(c==9)
  {
  cout<<"\nAgain re-enter value for "<<name;
  goto xyz;
  }

}

void putdata(int b)
{
if(b==0)
  {
  cout<<"\n\nProduct"<<b+1<<"==>"<<name;
  cout<<"\nCost of "<<name<<"(per bag):-"<<cost;
  cout<<"\nQuantity of "<<name<<" bought:-"<<quantity;
  cout<<"\nQuantity of "<<name<<" sold out:-"<<sold_out;
  cout<<"\nQuantity of "<<name<<" present:-"<<stock;
  }
else if(b==1)
  {
  cout<<"\n\nProduct"<<b+1<<"==>"<<name;
  cout<<"\nCost of "<<name<<"(per piece):-"<<cost;
  cout<<"\nQuantity of "<<name<<" bought:-"<<quantity;
  cout<<"\nQuantity of "<<name<<" sold out:-"<<sold_out;
  cout<<"\nQuantity of "<<name<<" present:-"<<stock;
  }
else if(b==2)
  {
  cout<<"\n\nProduct"<<b+1<<"==>"<<name;
  cout<<"\nCost of "<<name<<"(per kg):-"<<cost;
  cout<<"\nQuantity of "<<name<<" bought:-"<<quantity;
  cout<<"\nQuantity of "<<name<<" sold out:-"<<sold_out;
  cout<<"\nQuantity of "<<name<<" present:-"<<stock;
  }
else
  {
  cout<<"\n\nProduct"<<b+1<<"=>"<<name;
  cout<<"\nCost of "<<name<<"(per cubicfoot):-"<<cost;
  cout<<"\nQuantity of "<<name<<" bought:-"<<quantity;
  cout<<"\nQuantity of "<<name<<" sold out:-"<<sold_out;
  cout<<"\nQuantity of "<<name<<" present:-"<<stock;
  }
}
void update()
{
cout<<"Enter new cost of "<<name<<":-";
cin>>cost;
cout<<"\nEnter quantity of "<<name<<" you want to add:-";
int x4;
cin>>x4;
int x5;
x5=quantity+x4;
quantity=x5;
stock=quantity-sold_out;
}

void bill(item o)
{
strcpy(name,o.name);
cout<<"Enter quantity of "<<o.name<<" bought:-";
cin>>quantity;
cost=quantity * o.cost;
}

void print(int j1)
{
cout<<j1+1<<")Quantity of "<<name<<" purchased:-"<<quantity<<endl;
cout<<j1+2<<")Cost of "<<name<<" is Rs:-"<<cost<<endl;
}
void change(item o1)
{

int t=sold_out+o1.quantity;
sold_out=t;
int t1=quantity-t;
stock=t1;
}


};

int q6=0;
class customer
{
public:
char name1[50];
float cost2,q1,t,t1,t2,tax3,tax4,tax5,q2[5],q3[5],cost3[5],cost4[5];
float amp,amd,amp1;
char dd[9];
customer()
{
t=0,t2=0;
}
void get(item u,int u3)
{
cout<<"Enter quantity of "<<u.name<<" purchased:-";
cin>>q1;
cost2=u.cost*q1;
q3[u3]=q1;
cost3[u3]=cost2;
}
void put1(item u1)
{
cout<<"Quantity of "<<u1.name<<" purchased:-"<<q1<<endl;
cout<<"Cost of "<<u1.name<<" is:-Rs"<<cost2<<endl;
}
void update1(item u)
{
cout<<"Enter quantity of "<<u.name<<" want to add:-";
cin>>q1;
cost2=u.cost*q1;
}



};


int main()
{
clrscr();
fstream file;
item m[5],n[5],o,nx[5],no[5];
int v1;
char ans;
do
{
ABC:
cout<<"                               ASQUARE SALES\n\n";
cout<<"Press 1 to continue\n\n\n";
int d;
cin>>d;
if(d==1)
  {
  cout<<"Select any one alternative\n\n";
  cout<<"1)To load all new data\n2)To view current product details\n3)To update details related to item\n4)To make a bill\n5)To manipulate account of customer\n";
  }
  else
  {
  cout<<"\nWrong choice\n";
  goto ABC;
  }
int c;
cin>>c;

switch (c)
{
case 1:
      {
      ofstream outf("Stock.txt");
      for(int i=0;i<5;i++)
      {
      m[i].getdata(i);
      outf<<m[i].name<<" ";
      outf<<m[i].cost<<" ";
      outf<<m[i].quantity<<" ";
      outf<<m[i].sold_out<<" ";
      outf<<m[i].stock<<" ";
      outf<<"\n";
      }
      outf.close();
      }
      break;

case 2:
      {
      ifstream inf("Stock.txt");
      for(int j=0;j<5;j++)
      {
      inf>>m[j].name;
      inf>>m[j].cost;
      inf>>m[j].quantity;
      inf>>m[j].sold_out;
      inf>>m[j].stock;
      m[j].putdata(j);
      }
      inf.close();
      }
      break;

case 3:
      {
       cout<<"\n\nSelect correct alternative to update value\n\n";
       cout<<"1)Cement  2)Bricks  3)Steel  4)Sand  5)Kapchi\n";
       int l;
       cin>>l;
       m[l-1].update();
       ofstream outf("Stock.txt");
       for(int i=0;i<5;i++)
 {
 outf<<m[i].name<<" ";
 outf<<m[i].cost<<" ";
 outf<<m[i].quantity<<" ";
 outf<<m[i].sold_out<<" ";
 outf<<m[i].stock<<" ";
 outf<<"\n";
 }
       file.close();
      }
      break;
case 4:
      {
      cout<<"\nEnter no. of item purchased to prepare bill:-";
      int d;
      cin>>d;
      cout<<"\nEnter name of the cutomer:-";
      char f[50];
      gets(f);
      cout<<endl;
      float tc=0;
      for(int i=0;i<d;i++)
{
cout<<"\n1)Cement 2)Bricks 3)Steel 4)Sand 5)Kapchi";
cout<<"\nSelct item bought:-";
int e;
cin>>e;
n[i].bill(m[e-1]);
tc=tc+n[i].cost;
m[e-1].change(n[i]);
}

ofstream outf("Stock.txt");
for(int i1=0;i1<5;i1++)
{
outf<<m[i1].name<<" ";
outf<<m[i1].cost<<" ";
outf<<m[i1].quantity<<" ";
outf<<m[i1].sold_out<<" ";
outf<<m[i1].stock<<" ";
outf<<"\n";
}
outf.close();

cout<<endl<<endl<<"                  BILL AMOUNT"<<endl<<endl;
cout<<"                           "<<f<<endl;
      for(int j=0;j<d;j++)
{
n[j].print(j);
}
cout<<"\n\n\nTotal cost of the item:-RS "<<tc;
float tax;
tax=((12.5)*tc)/100;
cout<<"\nVat at the rate of 12.5%:-"<<tax<<endl;
float amt;
amt=tc+tax;
cout<<"\nTotal amount customer have to pay:-Rs "<<amt;
      }
      break;



case 5:
      {
      char ch[50];
      char nam[50];
      customer cc;
      cout<<"\n\n\n1)To prepare bill\n2)To open new account for customer\n3)To view details of particular customer\n4)To modify details of particular customer\n";
      int x2;
      cin>>x2;
      switch(x2)
   {
   case 1:
 {
 cout<<"Enter name:-";
 gets(ch);
 ifstream inf(ch);
 cout<<endl<<endl<<"                  BILL AMOUNT"<<endl<<endl;
 inf>>cc.name1;

 cout<<"                           "<<cc.name1<<endl;
      for(int j=0;j<5;j++)
 {
 inf>>cc.q1;
 inf>>cc.cost2;
 if(cc.q1>0)
   {
 cc.put1(m[j]);
   }
 }
 inf>>cc.t;
cout<<"\n\n\nTotal cost of the item:-RS "<<cc.t;
 inf>>cc.tax3;
cout<<"\nVat at the rate of 12.5%:-"<<cc.tax3<<endl;
 inf>>cc.amp;
cout<<"Amount paid by customer:-Rs"<<cc.amp;
 inf>>cc.amd;
cout<<"\nTotal amount customer due:-Rs===="<<cc.amd<<"===="<<endl;
 inf>>cc.dd;
cout<<"Due date is:-"<<cc.dd;
 inf.close();
 }break;
   case 2:
 {
 cout<<"Enter name of customer:-";
 gets(cc.name1);
 strcpy(nam,cc.name1);
 ofstream outf1(nam);
 outf1<<cc.name1<<" ";
 for(int v=0;v<5;v++)
    {
     cc.get(m[v],v);
     nx[v].quantity=cc.q1;
     m[v].change(nx[v]);
     cc.t=cc.t+cc.cost2;
     outf1<<cc.q1<<" ";
     outf1<<cc.cost2<<" ";
    }
    cc.tax3=(cc.t*12.5)/100;
    cc.tax4=cc.tax3;
    cc.t=cc.t+cc.tax3;
    cc.t1=cc.t;
    cout<<"Total cost of item including tax:-"<<cc.t;
    outf1<<cc.t<<" ";
    outf1<<cc.tax3<<" ";
 cout<<"\nEnter amount you want to pay:-";
 cin>>cc.amp;
 outf1<<cc.amp<<" ";
 cc.amd=cc.t-cc.amp;
 outf1<<cc.amd<<" ";
 cout<<"\nEnter due-date:-";
 cin>>cc.dd;
 outf1<<cc.dd<<" ";
 outf1.close();

ofstream outf("Stock.txt");
 for(int i1=0;i1<5;i1++)
    {
    outf<<m[i1].name<<" ";
    outf<<m[i1].cost<<" ";
    outf<<m[i1].quantity<<" ";
    outf<<m[i1].sold_out<<" ";
    outf<<m[i1].stock<<" ";
    outf<<"\n";
    }
    outf.close();

 }break;

      case 3:
    {
cout<<"Enter name:-";
 gets(ch);
 ifstream inf(ch);
 inf>>cc.name1;

 cout<<"                           "<<cc.name1<<endl;
      for(int j=0;j<5;j++)
 {
 inf>>cc.q1;
 inf>>cc.cost2;

 cc.put1(m[j]);
 }
 inf>>cc.t;
cout<<"\n\n\nTotal cost of the item including tax:-RS "<<cc.t;
 inf>>cc.tax3;
cout<<"\nVat tax at the rate of 12.5%:-"<<cc.tax3<<endl;
 inf>>cc.amp;
cout<<"Amount paid by customer:-Rs"<<cc.amp;
 inf>>cc.amd;
cout<<"\nTotal amount customer due:-Rs "<<cc.amd<<endl;
 inf>>cc.dd;
cout<<"Due date is:-"<<cc.dd;
 inf.close();
    }break;

   case 4:
 {
 cout<<"Enter name of customer:-";
 gets(cc.name1);
 strcpy(nam,cc.name1);
 ofstream outf1(nam);
 outf1<<cc.name1<<" ";
 for(int v=0;v<5;v++)
    {
    cc.q2[v]=cc.q3[v];
    cc.cost4[v]=cc.cost3[v];
     cc.update1(m[v]);
     no[v].quantity=cc.q1;
     m[v].change(no[v]);
     cc.t2=cc.t2+cc.cost2;
     outf1<<cc.q1+cc.q2[v]<<" ";
     outf1<<cc.cost2+cc.cost4[v]<<" ";
    }
    cc.tax5=(cc.t2*12.5)/100;
    cc.t=cc.t2+cc.tax5+cc.t1;
    outf1<<cc.t<<" ";
    outf1<<cc.tax4+cc.tax5<<" ";
 cout<<"\nAmount paid:-"<<cc.amp<<endl;
 cout<<"Amount due:-Rs "<<cc.amd+cc.t2+cc.tax5;
 cout<<"\nAmount you want to pay more:-";
 cin>>cc.amp1;
 cc.amp=cc.amp+cc.amp1;
 outf1<<cc.amp<<" ";
 cc.amd=cc.t-cc.amp;
 outf1<<cc.amd<<" ";
 cout<<"\nEnter due-date you want to change:-";
 cin>>cc.dd;
 outf1<<cc.dd<<" ";
 outf1.close();

ofstream outf("Stock.txt");
 for(int i1=0;i1<5;i1++)
    {
    outf<<m[i1].name<<" ";
    outf<<m[i1].cost<<" ";
    outf<<m[i1].quantity<<" ";
    outf<<m[i1].sold_out<<" ";
    outf<<m[i1].stock<<" ";
    outf<<"\n";
    }
    outf.close();

 }break;
 default:
 cout<<"\nWrong choice\n";
   }
      }

      break;



      default:
      cout<<"\nWrong choice\n";

}
cout<<"\n\nDo you want to continue again(y/n):-";
cin>>ans;

}while(ans=='y' || ans=='Y');
getch();
return 0;
}

No comments:

Post a Comment

Distributed By Free Blogger Templates | Designed By Seo Blogger Templates