In: Computer Science
C PROGRAMMING
Build a hotel management program. The user will register their name and put their check-in time and check-out time. They can choose their type of room they stay (Deluxe room, junior suite room, suite room, presidential suite room). Then, the program will determine the total price.
*NOTE
- Using modular, user-friendly, and array usage programming. Please
don't use struct/structure and pointer.
- Please give explanation about the code.
#include<stdio.h>
int price_list(int);
int main(void)
{
    char name[100];//storing customer's name
    int days;// how many days he / she want to stay
    char checkinTime[10];// to record the check in time
    char checkoutTime[10];// to record the check out time
    int choice;// choice of room
    printf("Please enter name:");
    gets(name);
    printf("Number of days:");
    scanf("%d", &days);
    printf("Enter Check in time (24 hr format):");
    getchar();
    gets(checkinTime);
    printf("Enter Check out time (24 hr format):");
    gets(checkoutTime);
    printf("-----PRESS-----\n1 for Deluxe Room\n2 for Junior Suite Room\n3 for Suite Room\n4 for Presidential Suite Room\nEnter:");
    scanf("%d", &choice);
    printf("---------DETAILS----------\n");
    printf("Customer:%s, staying:%d days, check in:%s, check out:%s, PRICE:%d\n", name, days, checkinTime, checkoutTime, days * price_list(choice));
    return 0;
}
int price_list(int choice)
{
    int arr[4] = {500, 1000, 1500, 2000};// prices for Deluxe Room, Junior Suite Room, Suite Room, Presidential Suite Room respectively
    return (arr[choice - 1]);// returning the price for respective choice of room, choice - 1 as index starts from 0
}
O/P:
