+ 2

Service Station - Programming Project

Can anyone help me with a programming project? The program needs to be able to accept an INT input. There also needs to be 3 bays where virtual cars will sit. Every cycle the counter increments by 1. In the first Bay one car sits for 2 cycles, second Bay is 3 cycles, and third Bay is 4 cycles. They then move to a Completed section and there is also a counter that keeps track of how many cars are completed. There will be a Holding Count and Cycle Count section as well. Any help is much appreciated!

1st Nov 2017, 5:29 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
21 Answers
+ 1
Finished the program. Worked on it for a while. Sending it in two messages because it's too long: #include <iostream> using namespace std; int carsFinished = 0; class Bay{ public: //Constructor and StartUp Call Bay(int n): cycles(n), totalCycles(n){ hasCar = false; } //When cycle passes int cycle(int holdC){ switch(hasCar){ case false: if(holdC != 0){ cycles -= 1; hasCar = true; cout << "Car entered into bay." << endl << endl; return 1; } else { cout << "No more cars to serve. " << endl; return 0; } case true: if(cycles > 0){ cycles -= 1; cout << "Service in progress..." << endl << endl; return 0; } else { cycles = totalCycles; cout << "Car finished." << endl << endl; carsFinished += 1; hasCar = false; return 0; } } }
3rd Nov 2017, 4:49 AM
Rain
Rain - avatar
+ 1
What do you mean by completed section? Where will the cars start off? Explain more. I understand the bays, but not where the cars will start or how they will move. What will we do with the INT input? You're very vague.
2nd Nov 2017, 9:10 PM
Rain
Rain - avatar
+ 1
It’ be easier if I could post an image of the layout. The program should first ask for an input (Int) Then the Output should contain the following: Holding Count (cars remaining to be serviced) Cycle Count (counts each cycle and increments by 1) Bay A (1 car completes every 2 cycles) Bay B (1 car completed every 3 cycles) Bay C (1 car completed every 4 cycles) Completed Count (number of cars completed) I hope this helps clear it up a little bit more. Like I said the diagram would make a lot more sense. Hard to explain with just text.
2nd Nov 2017, 9:45 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
The cars would go in order in regards to the Bays. For example, the first car would go to Bay A; the counter would increment by 1; a new car would move into Bay B; increment by 1 again; car in Bay A moved to completed, so there would be a new car in Bay A & Bay C during this cycle. And it would just continue like this.
2nd Nov 2017, 10:16 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
Just kinda how the code is supposed to look I guess. Just not sure where to start
2nd Nov 2017, 11:11 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
Basically if you put a 20 for the input it needs to show the correct output for all the following I outputs I mentioned above.
2nd Nov 2017, 11:53 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
The project isn’t very clear on this but I’m assuming it’s meaning how many cars there are.
3rd Nov 2017, 12:21 AM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
Awesome, man! I’ll have to check it out in a bit. I really appreciate the help. It should at least get me started.
3rd Nov 2017, 6:02 AM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
+ 1
Well it's everything you asked for. Just copy the first part into a c++ compiler, then copy the second part right under the first, and run it. It'll work perfectly.
3rd Nov 2017, 6:08 AM
Rain
Rain - avatar
+ 1
Ohhh ok man then I'll fix it after school today
7th Nov 2017, 4:04 PM
Rain
Rain - avatar
0
Ohhh ok I think I understand now. Still need help? If so, with what?
2nd Nov 2017, 10:51 PM
Rain
Rain - avatar
0
So what will we do with the input integer? Is it the amount of cars that need to be serviced?
2nd Nov 2017, 11:51 PM
Rain
Rain - avatar
0
What do we DO with the input though. Yes, we get a 20 and output stuff, but what does that 20 represent? I can start helping as soon as I know this.
3rd Nov 2017, 12:19 AM
Rain
Rain - avatar
0
private: const int totalCycles; int cycles; bool hasCar; }; int getTotalCars(){ int n; while(true){ cout << "Enter amount of cars to serve: " << flush; cin >> n; if(n <= 0){ cout << "Invalid amount." << endl; } else { cout << endl; break; } } return n; } int main(){ int holdingCount = getTotalCars(); //Total cars left to serve int const totalHoldCount = holdingCount; int cycleCount = 0; //Cycles that have passed by int sub = 0; int A = 2; int B = 3; int C = 4; Bay bayA(A); Bay bayB(B); Bay bayC(C); while(carsFinished < totalHoldCount){ cout << "Bay A: " << endl; sub += bayA.cycle(holdingCount); if(holdingCount > 0){ holdingCount -= sub; } sub = 0; cout << "Bay B: " << endl; sub += bayB.cycle(holdingCount); if(holdingCount > 0){ holdingCount -= sub; } sub = 0; cout << "Bay C: " << endl; sub += bayC.cycle(holdingCount); if(holdingCount > 0){ holdingCount -= sub; } sub = 0; cout << endl << "Cars left to serve: " << holdingCount << endl; cout << "Cars finished: " << carsFinished << endl; if(carsFinished != totalHoldCount){ cycleCount += 1; cout << "Cycles: " << cycleCount << endl << endl; } } cout << "All cars done." << endl; cout << "Total Cycles: " << cycleCount << endl; return 0; }
3rd Nov 2017, 4:50 AM
Rain
Rain - avatar
0
What would it look like if instead of entering the total amount of cars, the user entered the total amount of cycles to take place? Would it completely change the program?
6th Nov 2017, 8:32 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
0
Hmm... What if we had days instead. Each bay can do a certain number of cycles per hour. If in one day, each bay is open for 10 hours, then the input would be how many days we want the program to run. Then, maybe we could also insert money. Each one gets money for the completion of a car. At the end of the day, it displays house much money each bay made. If a car wasn't finished by the end of he day, then it would be continued on the next day. By the way, what is this project for?
7th Nov 2017, 2:30 PM
Rain
Rain - avatar
0
A Computer Organization & Architecture class. It shouldn’t require programming for this class, but for some reason we have to do this project...
7th Nov 2017, 3:02 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
0
And I believe it’s supposed to be just how the program you wrote is but with cycles as the input instead of days
7th Nov 2017, 3:03 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
0
I finally got some guidelines for the Project: There will be a Waiting Count which is the number of cars waiting to be serviced; this will be set to 1 at the very beginning. Next, there will be 3 Bays (A, B, C). This is where the cars will be serviced. A = 2 cycle counts; B = 3; C = 4. Lastly, there will be a Finished Bay; this is where the number of cars finished will be stored. This will also be output.
7th Nov 2017, 8:34 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar
0
1 cycle count = 1 car added to the Waiting Bay (count). For example, after the first cycle count, there will be 1 car in Bay A. Bay B & C will both be empty and there will be no cars completed yet. Cycle count 2 – there will be 1 car in Bay A & B. None in C or the finished. Cycle count 3 – A will move to Finished, and there will be 1 car in B & C. Therefore, the Waiting Count will increase overtime as the Bays won’t be able to clear fast enough. Also, the only thing the user INPUTS is the cycle count. The only thing that gets OUTPUT is “Finished Count” & “Numbers of Cars Still Waiting”. Think of it as there are THREE phases. 1) Numbers of cars Waiting o be serviced. 2) The 3 Service Bays. 3) Number of cars completed.
7th Nov 2017, 8:47 PM
Caleb Brooks Critz
Caleb Brooks Critz - avatar