/* Cafe inventory and accounts database */ #include #include #include #define MAXNAME 30 #define MAXPRODUCTS 200 typedef enum {false, true} bool_t; typedef struct { char name[MAXNAME]; double saleprice; int quantity; } stock_t; typedef struct { int numproducts; stock_t products[MAXPRODUCTS]; double balance; } cafe_t; typedef struct { char name[MAXNAME]; int quantity; double costprice; } order_t; cafe_t swedish; void initialiseSwedishCafe (void) { swedish.balance = 4100.00; swedish.numproducts = 5; strcpy(swedish.products[0].name, "BeetrootSoup"); swedish.products[0].quantity = 500; swedish.products[0].saleprice = 5.50; strcpy(swedish.products[1].name, "LeekandPotatoSoup"); swedish.products[1].quantity = 300; swedish.products[1].saleprice = 5.50; strcpy(swedish.products[2].name, "CranberryScone"); swedish.products[2].quantity = 80; swedish.products[2].saleprice = 2.20; strcpy(swedish.products[3].name, "Pizza"); swedish.products[3].quantity = 180; swedish.products[3].saleprice = 6.80; strcpy(swedish.products[4].name, "Coffee"); swedish.products[4].quantity = 2000; swedish.products[4].saleprice = 2.50; printf("Swedish cafe initialised.\n"); } double valueSwedishCafe (void) { /* BEGIN ANSWER (a) -- do not delete this line */ // ADD YOUR CODE HERE /* END ANSWER (a) -- do not delete this line */ } int quantityInStock (char *item) { /* BEGIN ANSWER (b) -- do not delete this line */ // ADD YOUR CODE HERE /* END ANSWER (b) -- do not delete this line */ } order_t readOrder() { /* BEGIN ANSWER (c) -- do not delete this line */ // ADD YOUR CODE HERE /* END ANSWER (c) -- do not delete this line */ } bool_t processOrder (order_t order) { /* BEGIN ANSWER (d) -- do not delete this line */ // ADD YOUR CODE HERE /* END ANSWER (d) -- do not delete this line */ } int main(void) { int choice, flag; char product[MAXNAME]; order_t ord; printf("Type 1 for initialise, 2 for valueSwedishCafe, 3 for "); printf("quantityInStock,\n 4 for readOrder (into ord), "); printf("5 for processOrder (from ord): "); scanf("%d", &choice); while((choice >= 1) && (choice < 6)) { if (choice == 1) initialiseSwedishCafe(); else if (choice == 2) printf("Current value of Swedish cafe assets is: %f\n", valueSwedishCafe()); else if (choice == 3) { printf("Which product are you interested in? "); scanf("%s", product); printf("The quantity of %s is %d.\n", product, quantityInStock(product)); } else if (choice == 4) { ord = readOrder(); } else { flag = processOrder(ord); printf("The order in 'ord' was processed successfully.\n"); } printf("Type 1 for initialise, 2 for valueSwedishCafe, 3 for "); printf("quantityInStock,\n 4 for readOrder (into ord), "); printf("5 for processOrder (from ord)."); scanf("%d", &choice); } printf("Not a valid choice, terminating.\n"); return EXIT_SUCCESS; }