Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void getUserInput(char[50], int , int);
- void getChosenPackage(int);
- float getPayment(float[]);
- int main()
- {
- char name[100],lead_name[10][10], month[100][100], so_homestay[];
- int check_in , check_out, total_days, chosen_homestay, fam_attend, t_children, t_adult;
- float to_pay;
- printf("===================================================================================");
- printf("\n=======================Welcome To A'Famosa Resort Homestay=========================");
- printf("\n===================================================================================\n");
- printf("Homestay A : ( 8 people recommended) (2 Bedrooms) (4Beds) (2 Baths) (RM400 Per Night)\n ");
- printf("Homestay B : ( 12 people recommended) (3 Bedrooms) (6Beds) (3 Baths) (RM500 Per Night)\n ");
- printf("Homestay C : ( 15 people recommended) (4 Bedrooms) (8Beds) (4 Baths) (RM600 Per Night)\n\n\n");
- printf("*all included: basic amenities(towels, iron,....) private pool, air-conditioning, tv, kitchen\n");
- printf("*not included : wifi, washer, heating\n ");
- printf("\n===================================================================================\n");
- fflush(stdin);
- printf("Reserver Name : ");
- gets(name);
- printf("Month of reserving : ");
- gets(month);
- printf("Date(Check in)(In number): ");
- scanf("%d",&check_in);
- printf("Date(Check out)(In number): ");
- scanf("%d",&check_out);
- printf("Total days : ");
- scanf("%d",&total_days);
- printf("Chosen homestay(number) ( A=1 , B=2, C=3) : ");
- scanf("%d",&chosen_homestay);
- printf("Number of Families attended : ");
- scanf("%d",&fam_attend);
- fflush(stdin);
- getUserInput(lead_name, t_adult , t_children);
- so_homestay[]= getChosenPackage(chosen_homestay);
- printf("===================================================================================\n");
- printf("Family leaders\t\tTotal Adult\tTotal Children\n");
- printf("===================================================================================\n");
- for(int i=0; i<fam_attend; i++)
- {
- fflush(stdin);
- printf("\n%s %d %d ",lead_name[i], t_adult[i], t_children[i]);
- }
- printf("===================================================================================\n");
- printf("Package chosen: %s",so_homestay);
- printf("Date : %d to %d %s",check_in , check_out, month);
- fflush(stdin);
- printf("Total payment : RM%f",to_pay);
- return 0;
- }
- void getUserInput(char lead_name[][50], int t_adult[], int t_children[],int fam_attend[])
- {
- for (int i=0; i<fam_attend; i++)
- {
- fflush(stdin);
- printf("Family %d Leaders name :", i+1);
- gets(lead_name[i]) ;
- fflush(stdin);
- printf("Total adult and total children (separate each input by space) : ");
- scanf("%d %d %d",&t_adult[i],&t_children[i]);
- }
- }
- void getChosenPackage(int chosen_homestay[], char so_homestay[][50] )
- {
- if (chosen_homestay=1)
- {
- strcpy(so_homestay,"Homestay A");
- }
- else if (chosen_homestay=2)
- {
- strcpy(so_homestay,"Homestay B");
- }
- else if (chosen_homestay=3)
- {
- strcpy(so_homestay,"Homestay C");
- }
- }
- float getPayment(int total_days, int chosen_homestay[])
- {
- float to_pay;
- if (chosen_homestay=1)
- {
- to_pay = 400*total_days;
- }
- else if (chosen_homestay=2)
- {
- to_pay = 500*total_days;
- }
- else if (chosen_homestay=3)
- {
- to_pay = 600*total_days;
- }
- return to_pay;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement