Write a c program that will deal with hotel reservations

Assignment Help C/C++ Programming
Reference no: EM131984717

Problem

Write a C program that will deal with reservations for a single night in a hotel with 3 rooms, numbered 1 to 3. It must use an infinite loop to read commands from the keyboard and quit the program (return) when a quit command is entered. Use a switch statement to choose the code to execute for a valid command. The valid commands are: R or r: reserve a room C or c: cancel a reservation W or w: remove a request from the waiting list L or l: list the current reservations for the night Q or q: quit the program Any other input: print an error message and prompt for another command.

You must use a linked list to represent the reservation list, and another linked list to represent the waiting list. You can determine whether each list will be singly- or doubly linked, and whether each list has just a front pointer, or a front and rear pointer. The two lists do not need to have the same design (that is one could be singly-linked with a front pointer, and the other doubly-linked with front and rear pointers. The reservation list can have at most as many nodes as there are rooms in the hotel Actions taken in response to a valid command (r, c, w, or l) must be implemented using programmer-defined functions, one per command. Any needed data must be passed to the functions, not declared globally. Implement reservation ids using a simple integer counter. Names will have fewer than 15 characters.

Actions for each command are:

Reservation: If there is a free room, reserve a room by inserting a node on the reservation list containing the next reservation id and the name associated with the reservation. When there is space available, print the reservation id for the person at the keyboard, and prompt for and read the name associated with the reservation. If there are no rooms, print an appropriate message and ask if the person wants to be entered on the waiting list. If they do, add a node to the waiting list array, print the reservation id for the person at the keyboard, and prompt for and read the name associated with the waiting list entry. The waiting list must be implemented as a queue (insert nodes at the back of the list and remove nodes from the front of the list when a room becomes available)

Cancellation: If there is a room reserved under that reservation id, cancel the reservation by removing the node associated with the reservation. Otherwise print a message that the id is not valid. If a room is cancelled and there are entries on the waiting list, remove the first entry on the waiting list and insert the data in the reservation list, then print a message indicating that reservation id is now confirmed. Note that, if the nodes on both lists are the same type, you can simply insert the node you removed from the waiting list into the reservation list.

Wait cancellation: If there is a waiting list entry with that reservation id, the node containing that reservation id should be removed from the waiting list. Otherwise print a message indicating that id is not on the waiting list.

List reservations: Print the reservation ids and associated names of all rooms that are reserved. Do not print anything for rooms that are vacant. If there are no rooms reserved, print a message indicating that. If there are any entries on the waiting list you should also print the reservation number and name of all elements on the waiting list.

Quit: end the program by returning from the main function. Any other command: print an error message and prompt for another command.

Use an integer counter for reservation ids that starts at 1. Reservation ids are not reused. Use another integer to keep track of the number of rooms reserved. Your solution will be for a boutique hotel with only 3 (very expensive) rooms. But make liberal use of #define statements so it would be trivial to adapt your solution to a larger hotel.

Reference no: EM131984717

Questions Cloud

How has the knowledge gained the past few weeks increased : How has the knowledge gained these past few weeks increased your chances of functioning as a computer security administrator?
Price investors would be willing to buy for preferred stock : The current rate of return investors require is 6.0%. What is the maximum price investors would be willing to buy for the preferred stock?
Elements associated to the procurement business process : Draw a simplistic mind map for organizational elements associated to the procurement business process.
Calculate value of each selected ordinary share investment : FINC20018 - calculate the value of each selected ordinary share investment in terms ofyour required rate of return - Rank the ten investments in order
Write a c program that will deal with hotel reservations : Write a C program that will deal with reservations for a single night in a hotel with 3 rooms, numbered 1 to 3. It must use an infinite loop to read commands.
Trappings of knighthood : Group C should post reflect on what Cervantes is saying about the trappings of knighthood. For your post, tell us whether or not you agree
How can the information from public speaking : How can the information from PUBLIC SPEAKING, combined with information from other courses, training
What are the requirements for claiming dependent : What are the requirements for claiming dependent(s). Is the head of household filing status claimed by Al appropriate? Explain
Write public set methods to set values for length and width : Write public set methods to set the values for length and width. Write public get methods to retrieve the values for length and width.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What is the output of the following function call after main

What is the output of the following function call, given the function shown after main?

  Consider the following schema of an online flight

consider the following schema of an online flight reservation agency.customercid lastname firstname dobflightfid

  What is the effective access time for memory

Let the page fault service time be 10 millisecond(ms) in a computer with average memory access time being 20 nanosecond(ns). If one page fault is generated for every 106 memory accesses, what is the effective access time for memory?

  What happens when c is a function of just one variable

What happens when C is a function of just one variable? Can you provide a geometric interpretation of what gradient descent is doing in the one-dimensional case?

  Represent the real numbers

Assume you are given a set of N

  Write a program in c tonbspreverse the order of elements on

write a program in c tonbspreverse the order of elements on a stack s using two additional stacks using one additional

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Print out each test score and the total

Write a program that will read in 2 test score. The instructor has decided to give each student 10 bonus point on each test.

  Boolean expressions with while loops

These questions explore using boolean expressions with while loops. If you get confused by the output as you work through these questions, you should review those pages in your textbook, with special attention to the operators &&, ||, and !

  Program to input the length of the side from the keyboard

write a program to input the length of the side from the keyboard ,use the class to obtain the areas of all shapes and display the results on the screen

  Chances for getting the loan

Slick will not be an active manager, his partner will run the business. What are his chances for getting the loan?

  Write a program using vectors and iterators

Create a program that uses at least two functions that will be called from your main. This program is a number game program that asks for parts of your phone and after manipulating it mathematically, eventually outputs your entire phone number. The d..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd