INTRODUCTION TO PROGRAMMING
DESIGN PROJECT 1: C++ PROGRAM TO CALCULATE THE LIQUID LEVEL OF A TANK
Spring 2016 Problem Statement: A tank is shown in Figure 1. The tank had four inlet pipes (A, B, C, and D) each controlled by a valve and an outlet pipe (E).
Figure 1. Tank Diagram
The initial level of liquid in the tank at time zero or t(0) is 495 gallons. Inlet A has a flow rate of 5 gallons per second. The valve for inlet A is open for 10 seconds and then closes for 10 seconds and this cycle repeats as shown in Figure 2.
Figure 2. Inlet A Flow Rate
Inlet B has a flow rate of 10 gallons per second. The valve for inlet B is open for 20 seconds and then closes for 20 seconds and this cycle repeats. Inlet C has a flow rate of 2.5 gallons per second. The valve for inlet C is open for 5 seconds and then closes for 5 seconds and this cycle repeats. Inlet D has a flow rate of 7.5 gallons per second. The valve for inlet D is open for 15 seconds and then closes for 15 seconds and this cycle repeats. Liquid continually flows out of outlet E at a rate of 20 gallons per second.
Develop a computer program using the engineering problem solving methodology to determine at which time the tank will be empty based upon the following conditions.
• If the valve for inlet A is open meaning liquid in flowing into the tank from inlet A, then the flow rate of inlet B is reduced by one half.
• The valve for inlet C can only be open if the valves for inlet A or B are closed.
• The valve for inlet D can only be open if two of the other three valves are open.
The results of the program should show in table format
A. Time steps (increments) of one second and the sum of the inlet flow rates (A+B+C+D) based on the above conditions
B. Time steps and the level of liquid in the tank. (Hints see page 142 of textbook_for an example of a C++ program to put values in a table and the tank will he empty before60 seconds or OM.
C. The program should also contain at least one if statement, one iflelse statement, one switch statement, and either a while loop or for loop.