Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Assignment

An office building has 5 floors (4 levels above ground and a basement at level 0). There are 8 offices per floor, labeled A - H.

This program will maintain data about the occupant type of employees in each office in the building. The data will be stored in a two-dimensional array. (Be sure to use all defined indexes -- i.e. do not SKIP array index 0 for rows or columns).

Each office will be categorized by the type of employee assigned to the office. Possible occupant type values are: EMPTY, LAWYER, PARALEGAL, ASSISTANT. The array should store the occupant type using an enumerated type.

This week the program will store data into a BINARY file, instead of a text file, between runs. The binary file, BUILDING.BIN, will contain data on all occupied offices (data on EMPTY offices will NOT be stored).

For each for occupied office, the following three pieces of data will be stored in the file, in binary format:

- floor (row) index within the array
- office (column) index within the array
- occupant type (enumerated type)

NOTE: Any office NOT listed in the data file will be assumed to be EMPTY.

The first time you run the program, the BUILDING.BIN file will not exist. Then after you run the program once, you will have a BUILDING.BIN file, which you can use for subsequent runs.

If the BUILDING.BIN file does not exist when the program begins (for example, on the first run), all offices will be assumed to be EMPTY.
Program Details

Write a modular program (minimum of NINE functions that have arguments or return values), to do the following:

a) Initialize a two-dimensional array, representing the offices in the building, to all EMPTY offices.

b) Check if the BUILDING.BIN file exists. If it does, read the data about the occupied offices from the file. (NOTE: Be sure to use an ifstream type variable to read from the file).

First read the floor index, the office index, and the occupant type values from the file. Then use the floor and office indexes to store the occupant type in the correct location in the 2D array.

Be sure to read the floor index, office index, and occupant type in the same order that they were written to the file. A program's correct interpretation of the binary data is dependent upon reading the data in the same order that it was originally written.

NOTE: After you read the data from the file, you will not be using the file again while the user modifies values. All modifications, in part d below, will be made in the 2D array. You will not access the file again until the user chooses to exit the program.

c) Using the data in the array, count and display the total number of Lawyers, Paralegals, and Assistants in occupied offices in the entire building to the screen.

Sample Output:

Current Office Status (40 total offices):
8 lawyers
10 paralegals
13 assistants
---
31 occupied offices

d) In a loop, allow the user to modify the occupant status of various offices.

i) Display the following office occupant status modification menu choices:

1 - Change office from occupied to empty
2 - Modify office occupant type
3 - Change office from empty to occupied
D - Done making modifications

Allow user to choose from menu. Validate choice and loop until valid choice is made.

ii) Neatly display all offices of the specified type only (either occupied or empty).

For example, if the user chooses to change the office occupant type (or change an office from occupied to empty), the program would display all occupied offices:

Occupied offices:
4A 4B 4D 4E 4F
3A 3B 3C 3D 3E 3F 3G 3H
2A 2B 2C 2E 2G
1A 1B 1C 1D 1E 1F 1G 1H
0A 0B 0C 0G 0H

So if the user chooses to change from empty to occupied, the program would display all empty offices instead.

NOTE: If there are zero offices of the specified type, instead issue an error message and return to the occupant status modification menu immediately.

iii) Ask for the user's choice from the list displayed

Read and error check the floor Number and office Letter from the user.

- Verify the floor number is in the correct range (0-4).
- Verify the office letter is in the correct range (A-H).

Loop until a valid the floor Number and office Letter are entered.

NOTES ABOUT USER INPUT:

1) You can make the following assumption about data entered by the user (i.e. you do not have to error check these situations):

If you request a number, the user will enter a number.
If you request a char, the user will enter a char.

Characters may be entered in either upper or lowercase

(both should be recognized as the same)

2) Array indexes begin at 0, so the program should transparently take care of converting the user's office letter choices from a letter to the correct numeric indexes in the array, and vice versa.

iv) Validate that the choice is of the type original requested (occupied or empty).

If the office requested is not the same type as originally requested type (For example, if the user chooses to change from occupied to empty, but then enters an office that is already empty), issue an error message saying so. Loop until the floor Number and office Letter are the correct type.

v) Modify the office status

1) If the user chose to change from occupied to empty (and the office was verified as occupied), simply mark the office chosen by the user as EMPTY in the array.

Then display a message confirming the change was made. Example:
Office 2C is now empty.

2) If the user chooses to change occupant type (and the office is verified as occupied) or if the user chooses change from empty to occupied (and the office is verified as empty), display an occupant type menu: LAWYER, PARALEGAL or ASSISTANT

Validate the user choice. Once a valid choice has been entered, change the office status stored in the array to the new value chosen.

Then display a message confirming the change was made. Example:

Office 2D is now occupied by a paralegal.

Continue to let the user modify office occupant statuses until s/he chooses "Done" from the office occupant status modification menu.

e) Again count and display the total number of Lawyers, Paralegals, and Assistants in occupied offices in the entire building to the screen (same as (c) above). Pause until the user is done viewing the data.

f) Save the data in the array back to the BUILDING.BIN file in binary format. (NOTE: Be sure to use an ofstream type variable to write to the file).

The data should overwrite the original BUILDING.BIN, if it previously existed.

Store ONLY the data on the occupied offices. This means that you will NOT be able to just write the entire array out to the file at once (because that would also save data on empty offices).

The array holds one enumerated value in each cell (EMPTY, LAWYER, PARALEGAL, or ASSISTANT). But your program will need to write out three data values for each occupied office (a floor index, an office index, and an office occupant type), so you can place the enumerated value back to the correct place when the data is later read.

Loop through each cell in the array. If the office is occupied, write the data (floor index, office index, and office occupant type) for that office out to the file.

Display a message indicating that the data has been saved.

g) Exit the program

Programming Notes:

1. Your program must conform to all CS362 Coding Standards specified in Content section 1.7.

2. This program should be of modular design (minimum of NINE functions that have arguments or return values), use proper parameter passing and prototypes.

The module breakdown should be logical, with main doing little more than call other functions, and the other functions each performing only one well-defined task.

3. All code will be structured C++ code. Object-oriented programming (classes, templates, etc) will not be used.

4. Your program should be thoroughly tested, and test data files should be submitted.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92076339
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Programming Language

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

  • 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