Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92822370

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As