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

  As a beginning business analyst

As a beginning business analyst, you have been tasked by the project manager to develop the system requirements related to the handling of outstanding purchase orders.

  Finding different sizes of newspaper for local newspaper

Comprise a specific recommendation regarding how many different sizes newspaper must offer.

  Significance of strategic management

Explain the significance of strategic management to support telecommunications planning model.

  Explain description design analyses

Description Design Analyses (perhaps include sub-categories for each process) Description of Units being Designed What do they remove? Explain how do they operate?

  First instruction executed if we start machine with counter

Suppose the memory cells at addresses 00 through 02 contain the following bit patterns. What would be the first instruction executed if we start the machine with its program counter containing 00?

  Information assets to estimate for risk management purposes

If the organization has three information assets to estimate for risk management purposes which vulnerability must be estimated for additional controls first? Which vulnerability must be evaluated last?

  Write the diffent entities or objects

Write the diffent entities or objects,logical processes,data flows, and dfata stores which are involoved. starting from time you submitted your time sheet.

  Explaining it solutions to enhance workflows

The final method to include IT is not to go "looking for IT solutions" just for sake of using IT. But to have IT at the table to truly think about ways to develop workflows.

  Ordering a burrito at a fast food mexican restaurant

Draw an activity diagram for ordering a burrito at a fast food mexican restaurant (e.g. Chipotle or Qdoba)

  Explain checksum detect all errors caused by odd number

Let the 32-bit hash function defined as concatenation of two 16-bit functions: XOR and RXOR. Will this checksum detect all errors caused by odd number of error bits? Describe.

  Describe some ways for the firsthand knowledge

Describe some ways in which the firsthand knowledge we have of some topic goes beyond what we are able to write down in a language. What accounts for our inability to express this knowledge?

  Draw a production system

Suppose that you must perform three tasks, X, Y, and Z. You can only do one task at a time, and once that task is done, you never redo it.

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