Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ warning: do not use vector to complete this exercise. Write a program to simulate a parking lot with 10 spots. The program will

in c++
image text in transcribed
image text in transcribed
warning: do not use vector to complete this exercise. Write a program to simulate a parking lot with 10 spots. The program will takes 10 integers ( 0 or 1 ) as input to indicate the initial states of the individual spots of the parking lot 0 means vacant and 1 means occupied. The user then enters a series of characters (either I or 0 with i means entering one car and o means one car leaving). When a car eiters the parking lot (le, the user enters an i), it will occupy the first avalable spot from the beginning When the user enters an O, the last cat in the parking lot will leave To simulate the above process, use a 10 integer array to represent the vacancy state of each siot (again, 0 means vacant and 1 means occupied). When the user enters an is, the program will turn the first 0 in the array to 1 if all elements are 1 (parking lot is full), then do nothing. When the user enters an ' ;, the program will turn the last 1 in the array to 0 . If all elements are 0 (parking lot is empty), then do nothing. The program will output the final state of the parking lot and the number of cars in the parking lot you can safely assurne that the user wil enter only r or ' o; For example, assume the user enters the following as the inital state of the parking lot 1100111100 then if the user enters the following sequence of Y and O by following a non-zero integer indicating the number of Y and 'o' the user may enter the final state of the parking lot will become. 1.110111000 Note that the third element becomes 1 as it was the first avallable spol, while the third to the last element becomes 0 as it was the lasi spot occupied by a car. Note that the third element becomes 1 as it was the first available spot, while the third to the last element becomes 0 as it was the last 5 occupied by a car. Given the above initial state of the parking lot, if the user enters the following sequence 6 1 1 0 1 0 0 the state of the parking lot will become 16111110000 Any attempt to hard code the results will result in a 0 for this exercise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Using the method of Sec. 7.6, solve Prob. 7.32. B

Answered: 1 week ago