Function prototypes lack parameters

Assignment Help Basic Computer Science
Reference no: EM13164638

Write a program that emulates the behavior of a bus. The bus must have a schedule ( a finite number of times for it to stop) and a certain capacity (number of passengers). In this program the bus has two states: stopped and going. Over time, events take place, such as stopping the bus ( for which the bus must already be going ), loading passengers, unloading passengers, or starting the bus. For each event, the current state of the bus must change accordingly. Each time the bus stops, it must load and unload passengers. The number of passengers that will be unloaded at every bus stop must be generated randomly. The number of passengers waiting for the bus at each stop is also generated randomly. The bus should load as many waiting passengers as possible without exceeding the bus capacity. Write a program that implements this model, with the following operation:

void stop_bus();   /* Stop the bus   */

void start_bus();   /* Start the bus   */

void load_pass(); /* Load passengers */

void unload_pass(); /* Unload passengers */

Note: These function prototypes lack parameters; add whatever parameters you feel are necessary so that the program works without global variables. The program's output should reflect the bus's actions by reporting each change in state, along with the number of passengers loaded and unloaded.

Hints:

Bus status transition diagram: ( Diagram in the link: https://www.dropbox.com/s/qwe455521mm9hex/BUS%20C%2B%2B.jpg )

Bus travel from the first station to the last station. In each station, bus needs to stop, unload passengers, load passengers, and start. However, based on the station, bus's status , and the number of passengers, those actions may do different things.

In the computation (or simulation), bus will repeat actions in each station. In such a iteration, siulation codes call functions stop_bus, unload_pass, load_pass, and start_bus. In a specific function, we need to handle all cases.

For example,

Load_passengers

Case 1: If bus status is "running", do noting (direct return)

Case 2: If bus is full, do nothing

Case 3: If bus is in the last station, do nothing

Case 4: If the number of passengers plus the number of wating people is more than the max capacity, only a part of waiting customers can get loaded (to change the number of passengers)

Case 5 : Or else, all waiting people get loaded (to change the number of passengers)

Inputs: station_id, max_station_id, bus_status, &passengers

Output: the number of people who get loaded

Unload_passengers

Case 1: If bus is "running", do nothing

Case 2: If bus is empty, do noting

Case 3: If bus is in the last station, all passengers get unloaded (to change the number of passengers to be 0)

Case 4: Or else, our program generates a random number which represents the unloaded passengers (to change the number of passengers)

Inputs: station_id, max_station_id, bus_status, &passengers,

Outputs: the number of people who get unloaded

Stop_bus

Case 1: if bus is in the first station, display "Welcome!"

Case 2: Or else display "We are in the station X."

Inputs: station id, &bus_status

Start_bus

Case1: If bus is in the last station, do nothing

Case 2: Or else display "We leave for our next station X"

Inputs: station_id, max_station_id, &bus_status

Reference no: EM13164638

Questions Cloud

Function that accepts a pointer to a c-string : Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. Also have it display the average number of letters in each word.
Write a program that prompts the user to enter the accounts : The program should pass these values to a function that returns the future value of the account after the specified number of months. The program should display the accounts future value.
Create a 1-dimensional (1d) array : Write a program to create a 1-dimensional (1D) array that contains 15 characters and display to the screen a count of the occurrences of each of the vowels a, e, i, o, and u in the array.
. write a segment of code that prints the number of elements : Assuming the array x has been defined as: int x[n]; for some n and that values have been assigned to all the elements. Write a segment of code that prints the number of elements between (but not including) the largest and smallest values in the array..
Function prototypes lack parameters : These function prototypes lack parameters; add whatever parameters you feel are necessary so that the program works without global variables. The program's output should reflect the bus's actions by reporting each change in state, along with the n..
How many bits are required in the address bus : You have been assigned to design a 8M x 32 bit memory board. You may use only 256K x 8 bit RAM chips with full parallel addressing.a) How many bits are required in the Address Bus of the whole board?
Design a phonecall class that holds a phone number : Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute. Overload extraction and insertion operators for the class.
Design a class named checkingaccount : Design a class named CheckingAccount that holds a checking account number, name of the account holder, and balance.include methods to set values for each data field and a method that displays all the account information. Create the class diagram a..
Determine the highest bit rate possible for a circuit : 1. Determine the number of conditions possible for a binary code

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Compare computerized process to manual process

ompare a computerized process to manual process. Write differences and the advantages and disadvantages of the computerized systems.

  Explain how to generate array of random numbers

For some general variables L and U, write a comment that explains how to generate a 1 x N array of random numbers whose values are between L and U.

  Describe valid advice for naming variables

Which of the given is valid advice for naming variables? To save typing, make most variable names one or two letters. to avoid conflict with names which others are using , utilize unusual or unpronounceable names.

  Determine many blocks of main memory in direct-mapped cache

Asumme that computer using direct-mapped cache has 2^24 words of main memory and cache of 64 blocks, where each cache block contains 16 words. How many blocks of main memory are there?

  Explaining accuracy when using training set data

Explain what can you say about accuracy when using training set data and when using separate percentage to train?

  Determine integer to divide maximum number of partial sums

Now, given sequence, can you determine the integer M (L ≤ M ≤ U) which divides maximum number of partial sums of the sequence?

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  Develop requirements traceability matrix

The GlobalUBid.Com Case Study will be used to develop a requirements traceability matrix describing and following the life of requirements in both the forward and backward direction.

  Prepare design proposal for new office network

Callingyou Inc is a growing company providing 24-7 telephone support services for numerous companies. They have asked you to prepare a design proposal for their new office network.

  Explain sequences of signals that occur on address bus

Explain the sequences of signals that occur on address bus, control bus, and data bus when a simple microcomputer fetches an instruction.

  Methods-majority of target audience can play applications

What are some methods that we can guarantee that majority of target audience can play applications?

  Define the term information systems planning and list

Identify the key participants in the systems development process and discuss their roles. ·  Define the term information systems planning and list several reasons for initiating a systems project.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd