1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <iostream>
#include <fstream>
#include <string>
//#include <conio.h>
using namespace std;
int farvardin[31],ordibehesht[31],khordad[31],tir[31],mordad[31],shahrivar[31],
mehr[30],aban[30],azar[30],dey[30],bahman[30],esfand[29];
float far[16],ord[16],khor[16],ti[16],mor[16],shahr[16],
meh[15],aba[15],aza[15],de[15],ba[15],esf[14],dar,s,z;
int j=0;
void output(float []);
int main()
{
ofstream list("list.txt",ios::app);
ofstream sal("sal.txt",ios::app);
ofstream farv("far.txt",ios::app);
string name;
int tedad,gheymatye,newadd,i=0,gheymateto,co=0,di;
cout<<"Enter '1' For Working with Stocks:"<<endl;
cout<<"Enter '2' For Show The List:"<<endl;
cin>>di;
switch(di)
{
case 1:
cout<<"Enter '1' For Adding:"<<endl;
cout<<"Enter '2' For Accounting:"<<endl;
cin>>newadd;
switch(newadd)
{
case 1:
//New Adding---------------------------------------------------------------------------//
cout<<"Enter your Stock Name:"<<endl;
cin>>name;
cout<<"Enter your Amount of stock:"<<endl;
cin>>tedad;
list<<name<<' '<<tedad<<" ";
cout<<endl;
break;
//end of Adding------------------------------------------------------------------------//
case 2:
//being of process--------------------------------------------------------------------//
string na;
int ted;
cout<<"Enter your Stock Name For Accounting:";
cin>>na;
ifstream list;
list.open("list.txt");
bool found = false;
while (list>>name>>tedad)
{
if(na==name)
{
cout<<"Enter Your Yesterday Price:"<<endl;
cin>>gheymatye;
s=gheymatye*tedad;
cout<<"Enter Your Today Price:"<<endl;
cin>>gheymateto;
z=gheymateto*tedad;
found = true;
}
}
if (!found)
{
cout<<"Error Stock Name was not found!";
break;
}
farvardin[i]=s;
i++;
farvardin[i]=z;
for(int k=0; k<=i; k++)
{
sal<<farvardin[k]<<endl;
}
s*=100;
dar=(s/z);
dar-=100;
cout<<"%"<<dar;
far[co]=dar;
for(j=0; j<=i; j++)
farv<<far[j]<<endl;
return 0;
}
case 2:
output(far);
}
}
void output(float far[])
{
int i;
int mah;
cout<<"Enter mounth:"<<endl;
cin>>mah;
if(mah==1)
{
for(i=0; i<j; i++)
{
ifstream farv;
farv.open("far.txt");
cout<<far[i];
}
}
}
|