C++代写:RPG155 Auto Building Drawing

代写C++基础画图作业,在console中打印出建筑。

Learning Outcomes:

Upon successful completion of this assignment, you will have demonstrated the abilities to:

  • code program logic using sequence and selection statements
  • read user input
  • write program output
  • perform arithmetic operations
  • use loops to repeat instructions and validate user data
  • use functions to modularize your program

Background Information:

For this programming project, you will be requied to write a C program that will ask for and validate user input and then generate the drawing of a multi-story building!

SPECIFICATIONS (REQUIREMENTS):

Your program will begin by asking the user how many floors the building will contain (any whole number from 1 to 50 inclusive). Next, your program must ask the user how many windows are to be displayed on each floor (any whole number from 1 to 20 inclusive). For each piece of user input, your program MUST validate the user’s selection and display an error message if invalid data is supplied.

The validation for EACH piece of user input will be achieved by calling the function:

1
int getValidData(int low, int high, char type);

This function continuously asks the user to enter a whole number value from low to high inclusive and once a correct value is supplied, returns that value.
If the parameter ‘type’ is ‘w’, then this function asks the user to enter information for the number of windows on each floor. If the parameter ‘type’ is ‘f’, then this function asks the user to enter information for the number of floors. In order to display the floors, you will need to complete the following functions:

1
void drawUpperFloors(int numOfWindows);

Given the number of windows, this function draws any main floor of the building. The number of windows drawn is determined by the value of the parameter ‘numOfWindows’.
Please take note of the following details:

  • a). Each window is exactly 3 characters wide and 3 rows high.
  • b). The first window (on the left) is exactly 2 columns away from the left | border of the building’s wall.
  • c). The top AND bottom of the window is drawn using the = character.
  • d). The side of each window is drawn using the | character.
  • e). The top of the building is drawn using the - character and the top of the window is drawn starting on the 3rd row.
  • f). The left and right sides of the building are drawn using the | character and the right side of the building is 2 columns away from the rightmost window.
  • g). Each window is separated from other windows using a single space (column).
  • h). The bottom of the floor is left blank with one extra row below the bottom of the windows.
  • i). The upper right and left corners of the floors are drawn using + character.

An example of a floor with 3 windows is:

+---------------+
|               |
| === === === | |
| | | | | | | | |
| === === === | |
|               |

An example of a floor with 1 window is:

+-----+
|     |
| === |
| | | |
| === |
|     |
1
void drawGroundFloor(int numOfWindows);

This function is almost identical to the drawUpperFloors( ) function except that the first window will be replaced with a door.
So, if the numOfWindows parameter is 2, then the ground floor will consist of 1 door and 1 window.

If the number of windows is only 1, then only a door will be drawn.
Please take note of the following details:

  • a). Each window (and door) is exactly 3 columns wide.
  • b). The bottom of the floor is drawn using the * character.
  • c.) All other details are similar to the drawUpperFloors( ) function.

An example of a ground floor with 5 windows woulb be:

+-----------------------+
|                       |
| === === === === === | |
| | | | | | | | | | | | |
| | | === === === === | |
| | |                   |
*************************

Output

Here is a sample run of the program (with the correct output):

Welcome to the PRG155 Auto Building Drawing Program
Please enter the number of floors (1 to 50): -2
*** Sorry, value (-2) MUST BE between 1 and 50 ***
Please enter the number of floors (1 to 50): 3
Thank You!
Please enter the number of windows on each floor (1 to 20): -9
*** Sorry, value (-9) MUST BE between 1 and 20 ***
Please enter the number of windows on each floor (1 to 20): 55
*** Sorry, value (55) MUST BE between 1 and 20 ***
Please enter the number of each floor (1 to 20): 8
Thank You!

+-----------------------------------+
|                                   |
| === === === === === === === === | |
| | | | | | | | | | | | | | | | | | |
| === === === === === === === === | |
|                                   |
+-----------------------------------+
|                                   |
| === === === === === === === === | |
| | | | | | | | | | | | | | | | | | |
| === === === === === === === === | |
|                                   |
+-----------------------------------+
|                                   |
| === === === === === === === === | |
| | | | | | | | | | | | | | | | | | |
| | | === === === === === === === | |
| | |                               |
*************************************

Submitting Your Assignment

Test your program on the C platforms that your instructor has specified. For submission purposes, your program must work on DevC++ version 5.11. For detailed submission requirements follow your instructor’s assignment submission guidelines.

Your program MUST use and code the functions specified or else will not be considered complete and MUST be resubmitted!

Run your program several times using the sample test data displayed BELOW:
Instructions:

Input set 1:
Number of Floors   0, -1, 70, 25
Number of Windows  60, -5, 6

Input set 2:
Number of Floors   1
Number of Windows  1

Input set 3:
Number of Floors   50
Number of Windows  20