|
#include
#include
using namespace std;
//integers
int client=0,pays=0,services=0;
//arrays
int clientID[999];
int service[999][6];
float pay[999][5];
int sort_ID[999];
int data[999][6];
int data1[999][5];
int num[999];
int count[3];
int sort_service[999][6];
int sort_temp[999][6];
int sort_temp2[999][6];
int sort_month[999][6];
//strings
string names[999];
string sort_names[999];
string clientName[999];
//functions
void add_Client(){
string name;
int Identifier;
cout<
cin>>Identifier;
cout<
cin>>name;
clientName[client]=name;
clientID[client]=Identifier;
client++;
}
void service_Registration(){
int ID,serviceType,callDuring,day,month,year;
cout<
cin>> ID;
cout<
cin>> serviceType;
cout<
cin>>callDuring;
cout<
cin>> day >> month >> year;
service[services][0]=ID;
service[services][1]=serviceType;
service[services][2]=callDuring;
service[services][3]=day;
service[services][4]=month;
service[services][5]=year;
services++;
}
float payment_Calculation(int minutes,int type){
float wage=0;
switch (type){
case 1: wage=(minutes*5)/3;
break;
case 2: wage=minutes*10;
break;
case 3: wage=minutes*40;
break;
case 4: wage=(minutes*20)/15;
break;
default: cout<
break;
}
return wage;
}
void payment_Registration(){
int ID,day,month,year;
float payment;
cout<
cin>> ID;
cout<
cin>>payment;
cout<
cin>>day>>month>>year;
pay[pays][0]=ID;
pay[pays][1]=payment;
pay[pays][2]=day;
pay[pays][3]=month;
pay[pays][4]=year;
pays++;
}
void all_clients_details(){
cout<
int wages=0,payments=0;
for (int i=0;i
cout<
cout<
cout<
for (int j=0;j
if (clientID[i]==service[j][0]){
wages+=payment_Calculation(service[j][2],service[j][1]);
}
}
for (j=0;j
if (clientID[i]==pay[j][0]){
payments+=pay[j][1];
}
}
cout<
cout<
cout<
}
}
void month_Details(){
int month,year,j=0;
cout<
cin>>month;
cout<
cin>>year;
for(int i=0;i
if (service[i][4]>=month && service[i][4]<=month && service[i][5]<=year && service[i][5]<=year){
sort_month[j][0]=service[i][0];
sort_month[j][1]=service[i][1];
sort_month[j][2]=service[i][2];
sort_month[j][3]=service[i][3];
sort_month[j][4]=service[i][4];
sort_month[j][5]=service[i][5];
j++;
}
}
cout<
for(i=0;i
int wages=0;
cout<
cout<
cout<
for(int k=0;k
if (sort_month[k][0]==clientID[i]){
wages+=payment_Calculation(sort_month[k][2],sort_month[k][1]);
if (sort_month[k][1]==1)
cout<
else
if (sort_month[k][1]==2)
cout<
else
if (sort_month[k][1]==3)
cout<
else
if (sort_month[k][1]==4)
cout<
cout<
}
}
cout<
}
}
void client_Details(){
string name;
cout<
cin>>name;
cout<
for(int i=0;i
if (clientName[i]==name){
cout<
cout<
cout<
int wages=0;
for(int k=0;k
if (clientID[i]==service[k][0]){
wages=payment_Calculation(service[k][2],service[k][1]);
if (service[k][1]==1)
cout<
else
if (service[k][1]==2)
cout<
else
if (service[k][1]==3)
cout<
else
if (service[k][1]==4)
cout<
cout<
}
}
int payments=0;
for(k=0;k
if (clientID[i]==pay[k][0]){
payments+=pay[k][1];
cout<
}
cout<
cout<
cout<
}
}
}
}
void delete_Client(){
int wages=0,payments=0;
string name;
cout<
cin>> name;
for(int i=0;i
if (clientName[i]==name){
for(int counter=0;counter
if (clientID[i]==service[counter][0])
wages+=payment_Calculation(service[counter][2],service[counter][1]);
}
for(counter=0;counter
if (clientID[i]==pay[counter][0])
payments+=pay[counter][1];
}
cout<
cout<
cout<
if (wages-payments!=0){
cout<
cout<
cout<
cout<
}
else
cout<
}
}
}
void Sorting(){
string temp;
int tempnum;
for (int i=0;i
sort_names[i]=clientName[i];
sort_ID[i]=clientID[i];
}
for (i=0;i
sort_service[i][0]=service[i][0];
sort_service[i][1]=service[i][1];
sort_service[i][2]=service[i][2];
sort_service[i][3]=service[i][3];
sort_service[i][4]=service[i][4];
sort_service[i][5]=service[i][5];
}
for (i=0;i
for (int j=i+1;j
{
if (sort_names[i]>sort_names[j]){
temp=sort_names[i];
sort_names[i]=sort_names[j];
sort_names[j]=temp;
tempnum=sort_ID[i];
sort_ID[i]=sort_ID[j];
sort_ID[j]=tempnum;
}
}
}
int s=0;
int b=0;
while (s
int r=0;
while (r
if (sort_service[r][0]==sort_ID[s]){
sort_temp2[b][0]=sort_service[r][0];
sort_temp2[b][1]=sort_service[r][1];
sort_temp2[b][2]=sort_service[r][2];
sort_temp2[b][3]=sort_service[r][3];
sort_temp2[b][4]=sort_service[r][4];
sort_temp2[b][5]=sort_service[r][5];
b++;
}
r++;
}
s++;
}
for (int e=0;e
int v=0;
int f=0;
int tt=0;
while (v
if (sort_ID[e]==sort_temp2[v][0]){
sort_temp[f][0]=sort_temp2[v][0];
sort_temp[f][1]=sort_temp2[v][1];
sort_temp[f][2]=sort_temp2[v][2];
sort_temp[f][3]=sort_temp2[v][3];
sort_temp[f][4]=sort_temp2[v][4];
sort_temp[f][5]=sort_temp2[v][5];
tt=v+1;
f++;
}
v++;
}
for (int z=0;z
for( int x=z+1;x
if (sort_temp[z][5]>sort_temp[x][5]){
int t=sort_temp[x][0];
int p=sort_temp[x][1];
int n=sort_temp[x][2];
int d=sort_temp[x][3];
int m=sort_temp[x][4];
int y=sort_temp[x][5];
sort_temp[x][0]=sort_temp[z][0];
sort_temp[x][1]=sort_temp[z][1];
sort_temp[x][2]=sort_temp[z][2];
sort_temp[x][3]=sort_temp[z][3];
sort_temp[x][4]=sort_temp[z][4];
sort_temp[x][5]=sort_temp[z][5];
sort_temp[z][0]=t;
sort_temp[z][1]=p;
sort_temp[z][2]=n;
sort_temp[z][3]=d;
sort_temp[z][4]=m;
sort_temp[z][5]=y;
}
}
}
int l=tt-f;
for(int u=0;u
sort_temp2[l][0]=sort_temp[u][0];
sort_temp2[l][1]=sort_temp[u][1];
sort_temp2[l][2]=sort_temp[u][2];
sort_temp2[l][3]=sort_temp[u][3];
sort_temp2[l][4]=sort_temp[u][4];
sort_temp2[l][5]=sort_temp[u][5];
l++;
}
}
cout<
for (int y=0;y
cout<
for(int h=0;h
if(sort_temp2[h][0]==sort_ID[y]){
if (sort_temp2[h][1]==1)
cout<
else
if (sort_temp2[h][1]==2)
cout<
else
if (sort_temp2[h][1]==3)
cout<
else
if (sort_temp2[h][1]==4)
cout<
cout<
}
}
}
}
void welcome(){
cout<
}
//Main function
int main(){
welcome();
int response,i;
while (response!=6)
{
cout<
cin>>response;
switch(response){
case 1: add_Client();
break;
case 2: service_Registration();
break;
case 3: payment_Registration();
break;
case 4: delete_Client();
break;
case 5: {
cout<
cin>>i;
if (i==1)
client_Details();
else
if (i==2)
all_clients_details();
else
if (i==3)
month_Details();
else
if (i==4)
Sorting();
else
if(i==5)
break;
}
}
}
return 0;
}
هيدا حل الطلب التالت
sort_temp2[l][0]=sort_temp[u][0];
sort_temp2[l][1]=sort_temp[u][1];
sort_temp2[l][2]=sort_temp[u][2];
sort_temp2[l][3]=sort_temp[u][3];
sort_temp2[l][4]=sort_temp[u][4];
sort_temp2[l][5]=sort_temp[u][5];
l++;
}
}
cout<<>
int>
if>
if>
الصديق هو الشخص الذي يعرف أغنية قلبك....... ويستطيع أن يغنيها لك عندما تنسى كلماتها........
ولا بد أن نقول: أجمل هندسة في الكون بناء جسر من الأمل على نهر من اليأس...!!
|