MUST BE WRITTEN IN OBJECT ORIENTED C++ STYLE ONLY, NO PROCEDURAL MUST USE CLASSE
ID: 663214 • Letter: M
Question
MUST BE WRITTEN IN OBJECT ORIENTED C++ STYLE ONLY, NO PROCEDURAL
MUST USE CLASSES
You may use any method of inputting your data to your program you wish. Note that you will need to create your own test data.
MUST WORK
Industrial engineering, it is sometimes necessary to simulate manufacturing and service operations for the purpose of improving efficiency and optimizing the system. In this problem you are to model a rapid oil change and lubrication business. The queue data structure can be used to do this. Assume that the station has the following:
A. There are three bays for changing oil
B. It takes 15 minutes to service each car
C. One car arrives randomly between every 2 and 20 minutes
D. At the end of a 12-hour day, all waiting car are sent away.
Write you program to model 30 days of operation. Determining the average waiting time for the cars and the total amount of idle time for the bays. Run your program 12 times to get an understanding of the variability of the results. Report all your answers.
Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
struct car{
clock_t inside;
};
queue<car*> myqueue;
void add(){
car *c = new car();
c->inside = clock();
myqueue.push(car);
}
int main() {
clock_t this_time = clock();
int t_car = 0;
ite = true;
double random;
clock_t give;
while(true){
srand(time(NULL));
if (ite == true){
give = clock();
}
if (ite == true){
random = rand() % 18 + 2;
ite = false;
}
else if (clock() - give == random) {
add();
t_car++;
ite = true;
}
if (myqueue.front()->inside - clock() == 15.0){
myqueue.pop();
t_car--;
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.