Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. int /* 0 is 7pm, 1 is 9pm */ tables[3][2] = {{0,0},{0,0},{0,0}}, /* 1 = half, 2 = full, 3 = B&B */ board[4] = {1, 1, 1 ,1};
  2. char *tablenames[3] = {"Endor","Naboo","Tatooine"}, *dinnertimes[2] = {"7pm", "9pm"};
  3.  
  4. void dinnerbooking()
  5. {
  6. int ID, i, x, timechoice;
  7. char tablechoice[20];
  8. do{
  9. printf("What is your Booking ID?: ");
  10. fflush(stdin);
  11. scanf("%d",&ID);
  12. } while(!(ID >= 0 && ID <= 3));
  13. if (board[ID] == 1 || board[ID] == 2){
  14. printf("Current tables available:\n");
  15. for (i=0;i<3;i++){
  16. for (x=0;x<2;x++){
  17. if (tables[i][x] == 0){
  18. printf("%s at %s\n",tablenames[i], dinnertimes[x]);
  19. }
  20. }
  21. }
  22. do {
  23. char input[100];
  24. printf("Enter the table and time you would like to book: ");
  25. fflush(stdin);
  26. gets(input);
  27. sscanf(input,"%s %d",tablechoice,&timechoice);
  28. } while (!(!strcmp(tablechoice,tablenames[0]) || !strcmp(tablechoice,tablenames[1]) || !strcmp(tablechoice,tablenames[2])) && (timechoice != 7 || timechoice != 9));
  29.  
  30. switch(tablechoice[0]){
  31. case 'E':
  32. tables[0][(timechoice == 9)] = 1;
  33. break;
  34. case 'N':
  35. tables[1][(timechoice == 9)] = 1;
  36. break;
  37. case 'T':
  38. tables[2][(timechoice == 9)] = 1;
  39. break;
  40. }
  41. printf("Your seat is booked :)");
  42. }
  43. else {
  44. printf("You can't book a dinner.");
  45. return;
  46. }
  47. return;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement