The process function will then need

Assignment Help C/C++ Programming
Reference no: EM13160995

Simulation of DMV queue Use the dynamic queue class to simulate customers arriving at the DMV and being serviced.

Customers arrive at random intervals. Each will be given a ticket with their name, a number and a time stamp. The customer will enter the queue to wait to be served. When a customer is served, they are taken out of the queue.

The DMV service agent will process this person for a certain amount of time and then go on to the next person.

In order to simulate the time of arrival of customers and the time of processing, you will need to use the localtime function, a wait function, and a random number generator. The random number should be between 1 and 5. Add customers to the queue by using a random number generator to choose a random number between 1 and 5.

Use this number as a parameter to the wait function. When the wait function ends, add them to the queue. When there are customers waiting, the DMV service agent function should dequeue a customer, generate a random number between 1 and 10 and use this number as a parameter to the wait function simulating the processing time for that person.

The process function will then need to find the time the person waited by calling the time function and finding the difference between the start and end timestamps. Save this time to an accumulator so that in the end you can find the average wait time for all customers.

Add 10 people to the line and process them. Each time you process someone, print out their ticket information. After all 10 have been serviced, print the average wait time. Below is an example of the time calls you will need and a wait function.

The time code below should help me with this process but I'm still very confused:

#include <ctime>

#include <iostream>
using namespace std;
void wait ( int seconds );
int main()
{
   
    wait(5);
   
    time_t rawtime;
    struct tm * timeinfo;

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    cout << timeinfo->tm_hour<< ":" << timeinfo->tm_sec;
   wait(5);
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    cout << timeinfo->tm_hour<< ":" << timeinfo->tm_sec;

    return 0;
}
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}

Reference no: EM13160995

Questions Cloud

Generate a sphere of diameter 3. create 3 vectors : Generate a sphere of diameter 3. Create 3 vectors representing the translation of this sphere along the x, y, and z axes. Generate the correct vectors given the description below: The sphere should be translated to (-10, -10, -10).
Describe the phenomenon of convergence : Describe the phenomenon of convergence in the vertebrateretina. Why is this important to us?
Retrieves a student name and three scores : Write an application that retrieves a student name and three scores per line from a text file. Process the values by calculating the average of the scores per student. Write the name and average to a different text file. Test your application with a ..
What is the difference between the scenario : One of the reasons that people also sleep with their mouthsopen-causing snoring- is sleep apnea. This can also be a very dangerous condition requiring some sort of treatment.
The process function will then need : The process function will then need to find the time the person waited by calling the time function and finding the difference between the start and end timestamps. Save this time to an accumulator so that in the end you can find the average wait tim..
Economic and social impoverishment of the maasai people : Land loss has been the most important factor responsible for the ongoing economic and social impoverishment of the Maasai people. The Maasai believe that restoring their land and livestock economy is the only sustainable solution to elevate poverty a..
O create a variable called nickname which has a nickname : 1.  Show the steps to create a variable called NICKNAME which has a nickname for you in it; make this variable available to the environment
What are yearly duration of daylight for quito : what are yearly duration of daylight for quito, ecuador(on equator), and for Mazatlan, mexico(on tropic of cancer)?
File format would you choose : What file format would you choose for the following tasks: 1. A cartoon strip 2. A 3D model for use on a multimedia presentation on the web

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Assessment system of a university

Write a program for Assessment system of a University

  Write a bouncing ball video game

The balls bounces within the screen where the two horizontal walls are fixed

  Create if-then statement with single alternative decision

Create the If-Then statement (or a flowchart with a single alternative decision structure) which assigns 20 to  variable y and allots 40 to variable z if variable x is greater that 100.

  Write program which inputs number of winning coupons

Write a program which inputs number of coupons you win and outputs how many candy bars and gumballs you can get if you spend all off your coupons on candy bars first and remaining coupons on gumballs in c++.

  Create the appropriate constructor, getters and setters

Create the appropriate constructor, getters and setters for the class. Create an instance of Student for each of the students listed above from array. Construct the instance with lastname, firstname, and job.

  Write a program the contains an array of 1000 elements name

Write a function named equals() that accepts two char arrays and return true if both arrays have the same characters in the same order. The function should return false otherwise. Write a simple main() function to test your function.

  Computing value of the return statement

In the following code snippet, what is the value of the return statement for x = 4 and n = 4? int foo(int x, int n)

  Create a text adventure game that uses pointers

Create a text adventure game that uses pointers. You have a rich, eccentric Uncle Billy who is soon to be deceased.

  C program to compute parking fare for customers

Write C program to compute parking fare for customers who park their cars in parking lot when following information is provided: A character showing type of vehicle: C for car, B for bus and T for truck

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  Assign passed value to function to return value

Assign passed value to this member and another function to return value. Your main should read the integer from an input data file, and write the output to the output data file.

  Grocery store program

This program draws upon several concepts that were covered in CptS 121 and should serve as a good refresher for CptS 122. Our store, Cougar Mart, maintains its inventory in a text file. Not being very tech savvy, the owner of Cougar Mart needs you to..

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