Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. void getUserInput(char[50], int , int);
  6. void getChosenPackage(int);
  7. float getPayment(float[]);
  8.  
  9. int main()
  10. {
  11. char name[100],lead_name[10][10], month[100][100], so_homestay[];
  12. int check_in , check_out, total_days, chosen_homestay, fam_attend, t_children, t_adult;
  13. float to_pay;
  14.  
  15. printf("===================================================================================");
  16. printf("\n=======================Welcome To A'Famosa Resort Homestay=========================");
  17. printf("\n===================================================================================\n");
  18.  
  19. printf("Homestay A : ( 8 people recommended) (2 Bedrooms) (4Beds) (2 Baths) (RM400 Per Night)\n ");
  20. printf("Homestay B : ( 12 people recommended) (3 Bedrooms) (6Beds) (3 Baths) (RM500 Per Night)\n ");
  21. printf("Homestay C : ( 15 people recommended) (4 Bedrooms) (8Beds) (4 Baths) (RM600 Per Night)\n\n\n");
  22. printf("*all included: basic amenities(towels, iron,....) private pool, air-conditioning, tv, kitchen\n");
  23. printf("*not included : wifi, washer, heating\n ");
  24. printf("\n===================================================================================\n");
  25.  
  26.  
  27. fflush(stdin);
  28. printf("Reserver Name : ");
  29. gets(name);
  30. printf("Month of reserving : ");
  31. gets(month);
  32. printf("Date(Check in)(In number): ");
  33. scanf("%d",&check_in);
  34. printf("Date(Check out)(In number): ");
  35. scanf("%d",&check_out);
  36. printf("Total days : ");
  37. scanf("%d",&total_days);
  38. printf("Chosen homestay(number) ( A=1 , B=2, C=3) : ");
  39. scanf("%d",&chosen_homestay);
  40. printf("Number of Families attended : ");
  41. scanf("%d",&fam_attend);
  42.  
  43. fflush(stdin);
  44. getUserInput(lead_name, t_adult , t_children);
  45.  
  46. so_homestay[]= getChosenPackage(chosen_homestay);
  47.  
  48.  
  49. printf("===================================================================================\n");
  50. printf("Family leaders\t\tTotal Adult\tTotal Children\n");
  51. printf("===================================================================================\n");
  52.  
  53.  
  54. for(int i=0; i<fam_attend; i++)
  55. {
  56. fflush(stdin);
  57. printf("\n%s %d %d ",lead_name[i], t_adult[i], t_children[i]);
  58. }
  59.  
  60. printf("===================================================================================\n");
  61.  
  62. printf("Package chosen: %s",so_homestay);
  63.  
  64. printf("Date : %d to %d %s",check_in , check_out, month);
  65. fflush(stdin);
  66.  
  67. printf("Total payment : RM%f",to_pay);
  68.  
  69. return 0;
  70.  
  71. }
  72.  
  73. void getUserInput(char lead_name[][50], int t_adult[], int t_children[],int fam_attend[])
  74. {
  75. for (int i=0; i<fam_attend; i++)
  76. {
  77. fflush(stdin);
  78. printf("Family %d Leaders name :", i+1);
  79. gets(lead_name[i]) ;
  80. fflush(stdin);
  81. printf("Total adult and total children (separate each input by space) : ");
  82. scanf("%d %d %d",&t_adult[i],&t_children[i]);
  83. }
  84. }
  85.  
  86. void getChosenPackage(int chosen_homestay[], char so_homestay[][50] )
  87. {
  88. if (chosen_homestay=1)
  89. {
  90. strcpy(so_homestay,"Homestay A");
  91. }
  92. else if (chosen_homestay=2)
  93. {
  94. strcpy(so_homestay,"Homestay B");
  95. }
  96. else if (chosen_homestay=3)
  97. {
  98. strcpy(so_homestay,"Homestay C");
  99. }
  100. }
  101.  
  102. float getPayment(int total_days, int chosen_homestay[])
  103. {
  104. float to_pay;
  105.  
  106. if (chosen_homestay=1)
  107. {
  108. to_pay = 400*total_days;
  109. }
  110.  
  111. else if (chosen_homestay=2)
  112. {
  113. to_pay = 500*total_days;
  114. }
  115. else if (chosen_homestay=3)
  116. {
  117. to_pay = 600*total_days;
  118. }
  119. return to_pay;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement