Question: Make a flowchart based on the following code: #include using namespace std; int main() { int Track1, Track2, Track3, Track4; cout < < Enter the

Make a flowchart based on the following code:

#include using namespace std;

int main() {

int Track1, Track2, Track3, Track4;

cout << "Enter the number of trains on Track 1. ";

cin >> Track1;

cout << "Enter the number of trains on Track 2. ";

cin >> Track2;

cout << "Enter the number of trains on Track 3. ";

cin >> Track3;

cout << "Enter the number of trains on Track 4. ";

cin >> Track4;

// Check the number of trains on each track and prioritize access to the output track nased on track with the highest number

if ((Track1 > Track2) && (Track1 > Track3) && (Track1 > Track4)) { if (Track1 > 4) { cout << "Track 1 has 1 train cleared and " << Track1 << "Train(s) stopped. Track 1 alert! ";

cout << "Track 2 has " << Track2 << " trains(s) stopped. ";

cout << "Track 3 has " << Track3 << " trains(s) stopped. ";

cout << "Track 4 has " << Track4 << " trains(s) stopped. ";

} else { cout << "Track 1 has 1 train cleared and " << Track1 << " train(s) stopped. ";

cout << "Track 2 has " << Track2 << " trains(s) stopped. ";

cout << "Track 3 has " << Track3 << " trains(s) stopped. ";

cout << "Track 4 has " << Track4 << " trains(s) stopped. "; } return(0);

}

if ((Track2 >= Track1) && (Track2 > Track3) && (Track2 > Track4))

{ if (Track2 > 4) { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has 1 train clearend and " << Track2 << " train(s) stopped. Track 2 alert! ";

cout << "Track 3 has " << Track3 << " train(s) stopped. ";

cout << "Track 4 has " << Track4 << " train(s) stopped. "; } else { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has one train cleared and " << Track2 << " train(s) stopped. ";

cout << "Track 3 has " << Track3 << " train(s) stopped. ";

cout << "Track 4 has " << Track4 << " train(s) stopped. "; } return(0); }

if ((Track3 > Track1) && (Track3 >= Track2) && (Track3 > Track4))

{

if (Track3 > 4) { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has " << Track2 << " train(s) stopped. ";

cout << "Track 3 has 1 train cleared and " << Track3 << " train(s) stopped. Track 3 alert! ";

cout << "Track 4 has " << Track4 << " train(s) stopped. "; } else { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has " << Track2 << " train(s) stopped. ";

cout << "Track 3 has 1 train cleared and " << Track3 << " train(s) stopped. ";

cout << "Track 4 has " << Track3 << " train(s) stopped. "; }

}

if ((Track4 >= Track1) && (Track4 >= Track2) && (Track4 >= Track3))

{ if (Track4 > 4) { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has " << Track2 << " train(s) stopped. ";

cout << "Track 3 has " << Track3 << " train(s) stopped. ";

cout << "Track 4 has 1 train cleared and " << Track4 << " train(s) stopped. Track 4 alert! "; } else { cout << "Track 1 has " << Track1 << " train(s) stopped. ";

cout << "Track 2 has " << Track2 << " train(s) stopped. ";

cout << "Track 3 has " << Track3 << " train(s) stopped. ";

cout << "Track 4 has 1 train cleared and " << Track4 << " train(s) stopped. "; } return(0); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!