Write a C++ computer program that simulates the action of an elevator that is out of order. After simulating the motion of the elevator, your program will display a bar chart that shows the number of times the elevator stays on each floor of a twenty-five-story building.
When you arrive on the scene to begin studying the elevator, it is on the twelfth floor of the twenty-five-story building. Every five minutes the elevator either moves up one floor or down one floor. There is the same chance that the elevator will move up as move down, it is totally random. Keep track of the number of times the elevator stays at each of the twenty-five floors and display that information as a bar chart using a character like an asterisk to represent each time the elevator stays on a particular floor.
For example, our elevator starts on the twelfth floor and moves up to the thirteenth floor, five minutes later it moves up to the fourteenth floor and after another five minutes it moves back down to the thirteenth floor. A portion of a bar chart showing the number of visits the elevator made to each floor might look like this:
Floor Number of Visits
----- -----------------------
17
16
15
14 *
13 **
12 *
11
10
This is only a portion of the output your program will produce. Your Bar Chart will include all 25 floors from 25 through 1. Your output will display the top floor (25) at the top and the bottom floor (1) at the bottom to properly represent the floors in the building.
Observe the elevator's behavior for a number of hours that is entered by your user. Do not forget to validate your users input. Your bar chart will show how many times the elevator visited each floor.
NOTES:
This assignment allows you to use an array, generate random numbers, interact with your user, validate input, control processing with repetition structures, and format output.
Example output:
Floor Number of Visits
----- ---------------------------
25
24
23
22
21
20
19
18 ****
17 ******
16 *********
15 ***************
14 *********************
13 ***********************
12 **********************
11 ****************
10 *****
9
8
7
6
5
4
3
2
1