Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction Engineers often work with logical operations. Logic is critical to dynamic control. An excellent example of this exists in transportation engineering. Conditional logic operations

image text in transcribed

image text in transcribed

Introduction Engineers often work with logical operations. Logic is critical to dynamic control. An excellent example of this exists in transportation engineering. Conditional logic operations are needed to manage the complex track schedules for light-rail transit LRT) systems. The following lab demonstrates input/output control for an LRT system. The operational logic of an LRT junction is to be implemented for user-defined input with a C++ program. Pre-lab Flowchart Before your lab class, draw a flowchart for your proposed program (see progranm specification below), See the Lecture 4 notes for information on how to draw a flowchart. Remember, a flowchart does NOT contain code. Rather, it is a visual description of an algorithm and is written in plain English. You may produce your flowchart on a computer and print it, or, you may NEATLY draw your flowchart by hand on a piece of paper. Your flowchart is due at the START of your lab class and is worth 20% of this lab's grade (see the APSC 177 Lab Guide) Program Specification Consider an LRT junction with four input tracks and one output track. The output track can handle only one train at a time. Therefore, the LRT junction will only clear one train for travel from amongst all the trains on all the input tracks. The one train cleared for travel is selected by a ranking of track priorities as follows: -The input track with the highest number of trains on it is given the highest priority and will have one train cleared for travel. All other trains on that highest priority track and on the other tracks are stopped. priority, from highest to lowest, is used: Track 4, Track 3, Track 2, Track 1 trains, an alert is generated for that track. - If equal numbers of trains exist on any input tracks, the following order of -If the highest priority track (with the cleared train) has four or more stopped Write a C+ program to Prompt the user to enter, and then read in, the number of trains on each input track. Compare the number of trains on each track to determine, and then display, the number of cleared or stopped trains on each track. Use "if statements and Boolean operators &&, 1I, and! (as appropriate) for condition control. When necessary, display an alert for the track that has a cleared train. - - Note: There are many ways that code can be written to successfully implement the above specifications. Try to think of the simplest and most straightforward method for your code. Design your program with a flowchart before writing code. This is critical. You want your code to be as easy to understand and follow (especially for your markers) as possible. Your program must generate input/output as shown in the following examples. Example 1 Enter the number of trains on Track 1. 4 Enter the number of trains on Track 2. 3 Enter the nunber of trains on Track 3. 2 Enter the nunber of trains on Track 4. 1 Track 1 has 1 train cleared and 3 train(s) stopped Track 2 has 3 train(s) stopped Track 3 has 2 train(s) stopped Track 4 has 1 train(s) stopped Example 2: Enter the number of trains on Track 1. 5 Enter the number of trains on Track 2. 4 Enter the nunber of trains on Track 3. 3 Enter the nunber of trains on Track 4. 2 Track 1 has 1 train cleared and 4 train(s) stopped. Track 1 alert! Track 2 has 4 train(s) stopped Track 3 has 3 train(s) stopped Track 4 has 2 train(s) stopped Example 3: Enter the number of trains on Track 1. 3 Enter the number of trains on Track 2. 1 Enter the nunber of trains on Track 3. 3 Enter the nunber of trains on Track 4. 2 Track 1 has 3 train(s) stopped Track 2 has 1 train(s) stopped Track 3 has 1 train cleared and 2 train(s) stopped Track 4 has 2 train(s) stopped Example 4: Enter the number of trains on Track 1. 1 Enter the number of trains on Track 2. 5 Enter the nunber of trains on Track 3. 3 Enter the nunber of trains on Track 4. 5 Track 1 has 1 train(s) stopped Track 2 has 5 train(s) stopped Track 3 has 3 train(s) stopped Track 4 has 1 train cleared and 4 train(s) stopped. Track 4 alert

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

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions