Question

In: Computer Science

C PROGRAMMING Build a hotel management program. The user will register their name and put their...

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.

Solutions

Expert Solution

#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:


Related Solutions

Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Tail of a File, C++ Program. write a program that asks the user for the name...
Tail of a File, C++ Program. write a program that asks the user for the name of a text file. The program should display the last 10 lines, or all lines if less than 10. The program should do this using seekg Here is what I have so far. #include<iostream> #include<fstream> #include<string> using namespace std; class File { private:    fstream file;    string name; public:    int countlines();    void printlines(); }; int File::countlines() {    int total =...
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
C programming. Write a program that prompts the user to enter a 6x6 array with 0...
C programming. Write a program that prompts the user to enter a 6x6 array with 0 and 1, displays the matrix, and checks if every row and every column have the even number of 1’s.
Write a program in c# that declare a variable and store user name jjohn in. Then,...
Write a program in c# that declare a variable and store user name jjohn in. Then, write a statement that will make your program display at the screen the content of that variable, followed by " I would like to know your height in centimeter. Please enter it:". Then, write a statement that will store the value entered by the user, allowing decimal numbers ie some precision, a fraction part. Finally, write statements (more than one can be needed) so...
C++ : Write a program that creates a login name for a user, given the user's...
C++ : Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the...
c++ In this program ask the user what name they prefer for their file, and make...
c++ In this program ask the user what name they prefer for their file, and make a file, the file name should za file. Get a number from the user and save it into the create file. should be more than 20 number in any order. print out all 20 numbers in a sorted array by using for loop, last print out its total and average. At last create a function in which you will call it from main and...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to input 2 numbers, a starting number x and ending number y Implements a while loop that counts from x (start) to y(end). Inside the loop, print to the screen the current number Print rather the current number is even or odd If the number is even , multiply by the number by 3 and print the results to the screen. If the number is...
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT