-
T_T Help Me
There were some calculation problems in my assignment , i hav to hand over my assignment on 19 november 2009 so please help me repair it .
#include <stdio.h>
#include <ctype.h>
struct CashierNuri
{int employeeNum;
char name[20];
double totalCollect;
};
typedef struct CashierNuri Teller;
Teller cashier[5];
double totalCollect (char,char);
int x=0;
char a, b;
float totalprice=0;
double price [2];
double totalCollect (char a,char b)
{if((a=='s')&&(b=='y'))
price[x] = 4;
else if((a=='s')&&(b=='n'))
price[x] = 3;
else if((a=='m')&&(b=='y'))
price[x] = 5;
else if((a=='m')&&(b=='n'))
price[x] = 3.5;
else if((a=='l')&&(b=='y'))
price[x] = 6;
else if((a=='l')&&(b=='n'))
price[x] = 4;
return price[x];
}
void main()
{printf("\t\t\tNURI CHICKEN RICE RESTAURANT\n\t\t\t\tReceipt\n");
for(int i=0;i<2;i++)
{printf("\nCashier %d\n",i+1);
printf("Input employee number:");
scanf("%d",&cashier[i].employeeNum);
printf("Input employee name:");
scanf("%s",&cashier[i].name);
for(x=0;x<2;x++)
{repeat:
fflush (stdin);
printf("\n%d. *Enter Meal Set:",x+1);
printf("\n (S/s) for small;\n (M/m) for medium;\n (L/l) for large.");
scanf("%c.0",&a);
a = tolower (a);
if((a!='s')&&(a!='m')&&(a!='l'))
{printf(" Mistakes occur,please enter again.\n");
goto repeat;}
else
{rep:
fflush (stdin); //the keyboard buffer
printf(" *Enter Change Drink:");
printf("\n (Y/y) for yes;\n (N/n) for no.");
scanf("%c.0",&b);
b = tolower (b);
if((b!='y')&&(b!='n'))
{printf(" Mistakes occur,please enter again.\n");
goto rep;}
else
{if((a=='s')&&(b=='y'))
printf(" Meal Price:RM4.00\n");
else if((a=='s')&&(b=='n'))
printf(" Meal Price:RM3.00\n");
else if((a=='m')&&(b=='y'))
printf(" Meal Price:RM5.00\n");
else if((a=='m')&&(b=='n'))
printf(" Meal Price:RM3.50\n");
else if((a=='l')&&(b=='y'))
printf(" Meal Price:RM6.00\n");
else if((a=='l')&&(b=='n'))
printf(" Meal Price:RM4.00\n");
else
printf("\nMistakes occur\nSorry....");
}
}
totalprice += totalCollect (a,b);
}
printf("\n\t\t\tPlease pay : RM%.2f",totalprice);
}
for(i=0;i<2;i++)
{printf("\n\nRecord cashier %d\n",i+1);
printf("Number\t : %d\n",cashier[i].employeeNum);
printf("Name\t : %s\n",cashier[i].name);
printf("Total collection : RM%.2f\n",totalprice);
}
}