Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

T he CS1 hospital receives a variety of new patients each day. At various times of the day patients are held in a temporary room

T he CS1 hospital receives a variety of new patients each day. At various times of the day patients are held in a temporary room until there is a determination made where the patient should be placed for their visit. The final bed assignments are added at the end of the day. There also are changes and updates that have to be made. These rearrangements are reflected and placed on a grid that contains all of the current days new room assignments.

You have been hired to program the daily floor updates for the hospital using the input provided from the head nurse and a file that contains the pre-existing grid of the floors. There are 5 floors with 8 rooms on each floor. The pre-existing grid is actually a two-dimensional array that contains the following numeric codes:

Vacant

Check out

Occupied

Nurse Station

Transfer

Utility room

These indicate the actions that must take place as updates to the grid. These updates have to be made to the floors (grid) first, and then the new patients are inserted into the vacant rooms.

Here are the basic requirements:

When rooms are checked out they may be filled with a transfer or with a new patient so check outs should be updated to vacancies.

When a room is vacant it can be filled with a transfer or with a new patient.

Transfers are to be handled first, before new patients. Transfers are to be moved to the first available room, and their existing room is eligible for new patients or for another transfer. You may have to transfer patients to a different floor.

After all transfers are completed and check outs have been completed, new patients may begin to move in.

Both the occupied, utility room, and the Nurse Station codes will not require any activity but they are also not available.

When accepting the user input, you are required to validate the input and also you will need to display the total number of rooms that are currently available. You must limit the user’s input to not be greater than that value.

The program must display the grid of rooms three times: 1) upon reading the file; 2) after the transfers and check outs but before the user input and; 3) final version of the completed grid. All codes will display as before except those that checked out (1), those will become occupied (2) or vacancies (0).

Strategy :

Open the file for reading.

Build and display the initial grid of rooms from the input file.

Remember that room 1, floor 1, is (0,0) on the grid.

Perform the checkout updates.

Perform the transfer updates.

Rebuild and redisplay the grid of rooms.

Ask the user for their daily new patient input (display the threshold and limit the number)

Update the new patients.

Rebuild and redisplay the grid of rooms.

Printing the grid of rooms

You read in the floor grid as a 2-dimensional array of integers for the sole purpose of file reading sanity. However, this is not how it will appear when you display it on the screen.

Transfers are represented by a ‘T’.

The Check outs are represented by a ‘C’.

Nurse work stations are represented by a ‘W’.

Occupied rooms are represented by an ‘O’.

A vacant room is represented by a ‘V’.

The utility rooms are represented by an ‘X’.

There are different ways to handle this so as long as it makes sense, I won’t interfere. If you want advice, see me during office hours or ask in class.

Code :

Use a two-dimensional array to represent the room grid.

Make sure that your input from the nurse’s station is valid (it is in the range of vacancies and it must be numeric).

At a minimum you are required to create the following functions to:

Read in the initial grid.

Display the current grid of rooms with current data on who is in what position.

Get the input from the nurse’s station.

Move the check outs.

Move the transfers ( important: see instructions below *).

Insert the new patients.

Calculate the number of vacancies.

Make sure you use call by value and call by reference properly.

Make sure you close the input file when you are finished reading it.

Use a header comment with your name and the description of the program.

Use pre and post condition comments for each function.

Use appropriate code comments.

Use appropriate variable names.

Use constants where appropriate.

Use good coding practices (i.e., spacing, indentation, etc.)

*For moving transfers, your function is required to create a char array of pointers. This array will hold the addresses of the vacant positions. You will allocate an array the size of the number of vacancies and load the dynamic array with the transfers. Note that you may use a dynamic array (bonus points) or a regular array of pointers. Then move all of the transfers to available rooms (mark them as OCCUPIED) using the pointer.

Input data:

(R1) 1 0 4 1 3 2 0 2
(R2) 2 0 4 3 0 0 2 0
(R3) 2 0 2 0 3 4 0 2
(R4) 2 4 1 3 0 0 2 2
(R5) 1 2 0 4 3 1 2 5

Step by Step Solution

3.51 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

Code include include include using namespace std void writeFil... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Document Format ( 2 attachments)

PDF file Icon
609b2b2fd4159_31393.pdf

180 KBs PDF File

Word file Icon
609b2b2fd4159_31393.docx

120 KBs Word File

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Quantitative Methods For Business

Authors: David Anderson, Dennis Sweeney, Thomas Williams, Jeffrey Cam

11th Edition

978-0324651812, 324651813, 978-0324651751

More Books

Students also viewed these Programming questions

Question

1.The power a State has relative to Intrastate Commerce is:

Answered: 1 week ago

Question

explain the multidimensional model of sport leadership;

Answered: 1 week ago

Question

discuss the four components of effective leadership.

Answered: 1 week ago