Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

It can place a financial burden on families and the public.

Answered: 1 week ago