a program for school but need assistance.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

its supposed to be a program to display a main menu,then a display, calculate the lunch order for the customer to pay,make reservations and save it to a file then display it.Also it get the stock for how many lunches will be served for the day for specific dishes then update it by telling how many lunches are left after every purchase.This part I'm having alot of trouble with so i need help with this.Any other suggestions for any functions or for anything that make my program more efficient are welcome.Thanks.


#define MAXITEMS 31
#define LIMIT 4

typedef struct {
float time;
int party;
char name[30];
char day;
int pnum;
}reservationrecord;

typedef struct
{

}employeerecord;

typedef struct {
char name[10];
int orders;
int cost;
}stockrecord;

typedef struct {
char l_dish[40];
int dishesnum;
float dishprice;
}stockdatarecord;

typedef struct {
float price;
int orders;
float amountdue;
}payrecord;

void printline(); //prototype
void displaygoodbye(); //prototype
char displaymenu(char choice); //prototype
void displaylunchmenu(); //prototype
getstock( struct stockdata); // prototype
int main()
{

FILE *f1, *f2, *f3;
char filename[] = "my_stock.dat";
struct reservation customer [LIMIT];
struct stock item [MAXITEMS];
struct employee user;
struct stockdata dish;
struct pay receipt;
int reservhours [5]={6,7, 8, 9, 10};
int count,i;
char choice;


printline();

char displaymainmenu(char choice);


switch ( char choice)
{
case 'm': case 'M':
displaylunchmenu();
calculatelunchorder();
break;

case 'r': case 'R':
makereservation();
break;
case 'u': case 'U':
break;
updatestock();
case 'q': case 'Q':
displaygoodbye();
break;
default :
printf("That's an invalid option");

}



system("PAUSE");
return 0;
}
//______________________________________________________________________________
void printline()
{
printf("________________________________________________________________\n\n");
}
//______________________________________________________________________________
displaymainmenu (char choice)
{

printf("*************WELCOME TO PFC*******************\n");
printf("The only restaurant you'll ever need.\n\n");
printf("M: make lunch order.\n");
printf("R: make reservations.\n");
printf("U: update stock.\n");
printf("Q: quit menu.\n");
scanf(" %c",&choice);
return choice;
}
//______________________________________________________________________________
void displaygoodbye()
{
printf("Thank you for choosing PFC :).\n");
printf("The only restaurant you'll ever need.\n");
return;
}
//______________________________________________________________________________
displaylunchmenu()
{
printf("******LUNCH ORDER*******\n\n");
printf("What would you like to order?\n\n");

printf("1. Fried chicken with rice and peas for $300.\n");
printf("2. Curried goat with rice and peas for $350.\n");
printf("3. Stew peas for $350.\n");
printf("4. Pork with beans for $400.\n");
printf("5. Beef with rice and peas for $400.\n");
printf("6. Stew chicken and rice and peas for $300.\n");
printf("7. Oxtail with rice and peas for $450.\n");
printf("8. Quit\n\n");
return;
}
//______________________________________________________________________________
getstock(struct stockdata )
{
f1 = fopen("my_stockfile.txt", "r");
if (f1 != NULL)
{
while (( strcmp (dish.l_dish, "end" != 0)
{
printf("Enter the name of the dish.");
scanf(" %s", dish.l_dish);
printf("Enter the number of orders of that dish.");
scanf(" %d",dish.dishesnum);
printf("Enter the price of the dish.");
scanf(" %f", dish.dishprice);

printf("Enter another a dish name, type 'end' to finish\n");

scanf(" %d", dish.l_dish);
fclose(f1);

}
}
else
{
puts("Error-File 'my_stockfile.txt' not found");
}
return 0;
}
//______________________________________________________________________________
login(struct employee user )
{
char username1[]= "pfcadmin";
char username2[9] ;
char password1[]= "kingpin";
char password2[8];
char valid= 'F';
printf(" Enter your username.");
scanf(" %s", employee.username2);
if (strcasecmp (username1,username2)==0)
{
printf("\n\n Enter your password.");
scanf(" %s",password2);
if (strcmp(password1,password2)==0)
{
valid = 'T';
puts("Valid sign on attempt.");
}
else
{
puts("\n Invalid sign on attempt");
}
}
else
{
puts("Invalid sign on attempt.");
}
return valid;
}
//______________________________________________________________________________

updatestock(int i,struct stockdata)

i=0;
f2=fopen("my stock.txt", "w")
if (f2!= NULL)
{
while(i!=EOF)
{
stockdata[i].numofdishes==stockrecord.orders;
i=i+1;



//______________________________________________________________________________
makeresevation( struct reservationrecord,int count,reservhours[5])

{
f3=fopen("Reservationfile","w");
for (count = 0; count < LIMIT; count++)
{
puts("Name: ");
scanf(" %s", customer[count].name);
puts("Phone number in the form 999-9999");
scanf(" %d", customer[count].pnum);
puts("Time you would like have dinner");
scanf(" %d", customer[count][reservhours].time);
puts("How many many guests you will be entertaining?");
scanf(" %d", customer[count].party);
puts("Day you would like: ");
scanf(" %s", customer[count].day);
}
fclose(f3);


return 0;
}
//______________________________________________________________________________
showreservations ( struct reservation rec, int count)
{
puts("Reservations for today");

for (count = 0; count < LIMIT; count ++)
{
printf(" %s \t %d \t %d\n", customer[count].name ,customer[count].time,customer[count].party);

}
return 0;
}
//______________________________________________________________________________
calculatelunchorder(displaylunchmenu(),int j,struct pay rec)
{
for(j=0, i<=5,i--)
{
printf("What is the number of dishes you ordered?\n");
scanf("%d", &pay.orders);
printf("What is the price of dish you ordered?\n");
scanf("%f", &pay.price);
pay.amountdue= pay.orders * pay.price;
printf(" Your lunch order will amount to $ %.2f",pay.amountdue);
}
return 0;
}


Last edited on
So what do you need assistance with?
closed account (zb0S216C)
Could you please use code tags and specify what you need help with? I know C++ skips white-space but don't you think you're taking it to far after i=i+1;?
its supposed to be a program to display a main menu,then a display, calculate the lunch order for the customer to pay,make reservations and save it to a file then display it.Also it get the stock for how many lunches will be served for the day for specific dishes then update it by telling how many lunches are left after every purchase.This part I'm having alot of trouble with so i need help with this.Any other suggestions for any functions or for anything that make my program more efficient are welcome.Thanks.
Topic archived. No new replies allowed.