برنامه ورود و خروج ماشین ها از پارکینک
include
#include
long tag[99];
float tot[99]={200};//tot=total to pay
int i=0;
#define ph 100;//ph=price per hour
char ch;
short h[99], min[99], tmins[99], st[99]={0}, eh[99], emin[99];//h=arrive hour, min=arrive minute, tmins=total minutes in parking, st=car status, eh=exit hour, emin=exit minute
void list();
void search();
void add();
void page();
void show(int);
void ex();
void main()
{
page();
}
void page()
{
clrscr();
cout<<"\t\t\t\tWelcome!"<
<<"\n\tPress 2 to report an exiting car"
<<"\n\tPress 3 to see the list and search a car"<
switch(ch)
{
case 49: add(); break;
case 50: ex(); break;
case 51: list(); break;
}
}
void show(int t)
{
clrscr();
cout<<"Tag\tEnter\tMins before exit\tTo pay\t\tStatus\n\n";
cout<
cout<<"Still in\t";
else
cout<
cout<<"In the parking";
else
cout<<"Out";
cout<<"\n\nPress any key to continue";
getch();
page();
}
void add()
{
clrscr();
cout<<"\"Enter 0 as the tag to quit adding\"\n\n";
for(;4;i++)
{
cout<<"Tag: ";
cin>>tag[i];
if(tag[i]==0)
{
i--;
page();
}
cout<<"Time (As this structure: H:Min): ";
cin>>h[i]>>ch>>min[i];
if(h[i]==0&&min[i]==0)
{
i--;
page();
}
if(min[i]>59)
{
cout<<"Error, Try again\n";
i--;
continue;
}
cout<<"\n";
}
}
void search()
{
long t;
cout<<"\nTag to search(Enter 0 to go to main page): ";
cin>>t;
if(t==0)
page();
for(int c=0;c<=i;c++)
if(tag[c]==t)
{
show(c);
break;
}
cout<<"Wasn't found!";
}
void list()
{
clrscr();
cout<<"Tag\tEnter\tMins before exit\tTo pay\tStatus\n\n";
for(int t=0;t<=i;t++)
{
cout<
cout<<"Still in\t";
else
cout<
cout<<"In the parking";
else
cout<<"Out";
cout<<"\n";
}
search();
}
void ex()
{
clrscr();
long itag;
short m=-1;
cout<<"\"Enter 0 as the tag to quit removing\"\n\n";
while(4)
{
cout<<"Tag: ";
cin>>itag;
if(itag==0)
page();
for(int c=0;c<=i;c++)
if(tag[c]==itag)
{
m=c;
break;
}
if(m==-1||st[m]==1)
{
cout<<"Tag was not found in parking!"<
getch();
ex();
}
cout<<"Time (As this structure: H:Min): ";
cin>>eh[m]>>ch>>emin[m];
if(emin[m]>59)
{
cout<<"Wrong time! Press any key to try again";
getch();
ex();
}
tmins[m]=((eh[m]-h[m])*60)+(emin[m]-min[m]);
tot[m]+=((tmins[m]/60)-1)*ph;
st[m]=1;
cout<<"\nTo pay: "<
}
//end
نظرات شما عزیزان: