هادا برنامج لشركة سيارات كتبه بستراكت ممكن حدا يحوله لكلاس
#include <iostream.h>
#include <process.h>
#include <fstream.h>
fstream stfile;
struct car
**
int num,volume,engine;
char color[10];
char model[10],name[10],address[10];
long cost,no,code;
};
int i=-1,s;
car st [10];
void insert (car []);
void sale (car []);
void searching (car []);
void deleting (car []);
void display (car []);
void search (car[]);
void main ()
**
int n;
do
**
system("cls");
cout<<endl;
cout<<endl;
cout<<"\t\t_______________________________________ __________"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t1.inserting : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t2.Sale : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t3.searching : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t4.deleting : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t5.display : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t6.search the car sale : \t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t7.exit : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t_______________________________________ __________"<<endl;
cout<<endl;
cout<<"\t\t**********************\n";
cout<<"\t\t* enter the number *\n";
cout<<"\t\t**********************\n";
cout<<"\t\t\t\t\t"; cin>>n;
cin.ignore();
switch(n)
**
case 1:
system("cls");
cout<<endl;
cout<<"to insert data of car....\n";
insert (st);
break;
case 2:
system("cls");
cout<<endl;
cout<<"to sreaching about car in the company....\n";
sale (st);
break;
case 3:
system("cls");
cout<<endl;
cout<<"to sale car.....\n";
searching (st);
break;
case 4:
system("cls");
cout<<endl;
cout<<"to deleting car......\n";
deleting (st);
break;
case 5:
system("cls");
cout<<endl;
cout<<"to display data of car.......\n";
display (st);
break;
case 6:
system("cls");
cout<<endl;
cout<<"to search bout car sale.......\n";
search (st);
break;
default:
system("cls");
cout<<"try again...\n";
break;
}
}
while (n!=6);
}
void insert (car st[])
**
cout<<"enter the model of car :";
cin>>st.model;
cout<<"enter the code of the car:";
cin>>st.code;
cout<<"enter the color of the car :";
cin>>st.color;
cout<<"enter the power of engine :";
cin>>st.engine;
cout<<"enter the volume:";
cin>>st.volume;
i++;
void saving (car st []);
stfile.open("car.txt",ios::out|ios::in);
for (int f=-1;f<i;f++)
**
if (st.code!=0)
**
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
stfile.close();
}
}
void sale (car st[])
**
cout<<"enter the name of the cust.:";
cin>>st.name;
cout<<"enter the addresss of the cust.";
cin>>st.address;
cout<<"the num of cust:";
cin>>st.no;
cout<<"the cost of car:";
cin>>st.cost;
for (int s=-1;s<=i;s++)
**
if (st.no==s)
**
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}
void searching (car st[])
**
long code,engine;
char color;
int i;
cout<<"enter the code of the car:";
cin>>st.code;
cout<<"enter the color of the car :";
cin>>st.color;
cout<<"enter the power of engine :";
cin>>st.engine;
for (int s=-1;s<=i;s++)
**
if (st.code!=0)
**
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}
void deleting (car st[])
**
long l;
cout<<" write the code of the car which delete it:";
cin>>l;
system("cls");
for (int n=-1;n<=i;n++)
**
if(st[n].num==l)
**
st[n].num=0;
cout<<"the clear of the car datas complete"<<endl;
}
cin.get();
}
}
void search (car st[])
**
long code;
cout<<"write the code of the car which looks for it:";
cin>>code;
for (int s=-1;s<=i;s++)
**
if (st.code!=0)
**
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}
void display (car st[])
**
for (int s=-1;s<=i;s++)
**
if (st.code!=0)
**
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}

