Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code must be written in C. Thank you so much! A toxic waste product from a chemical process, A, is treated in a holding tank

image text in transcribed
image text in transcribed
image text in transcribed
Code must be written in C. Thank you so much!
A toxic waste product from a chemical process, A, is treated in a holding tank with a bacterial agent that causes it to decompose. For example, in the following table, the initial concentration of A in the tank is CA(0)= 10.0 mol A/Liter. Samples are frequently drawn from the reactor and analyzed for A, leading to the following data, where t is the elapsed time of A in the tank: We want to determine an expression for CA(t) such that we can determine the holding time required for A to fall below its safe value of, for example, 0.001 mol/L. That is, we want to know how long it will take for the bacteria to "detox" the toxins to a safe level of 0.001mol/L The engineers plot the data and find that the curve looks like an exponential decay, so they try CA(t)= kert (with the expectation that the parameter r is negative). Given this curve model, they want to compute a and b to specify the model. The first step they have done is to linearize the equation by taking the natural log function on both sides. The new equation is: lnCA(t)=rt+lnk To calculate k and r from the samples, a numerical method called the least square method is used. How does the least square method work? Assume that two data series, y and x, have a linear relationship: y=mx+a. To discover m and a, scientists and engineers usually sample x and y numerous times. Assume the number of times is n. Then m and a can be computed using the following equations: m=ni=1nxi2(in1nxi)2ni=1nxiyiinw1xiin1yia=ni=1nyimi=1nxi IMPORTANT NOTE: In this assignment, you should consider lnCA(t) as the y serles, and t the x series. The results that you obtain from solving the equations are: k=ea( that is, a=lnk) and r=m. (4) You have been tasked to design and implement a program to do the following: 1. (2 points) Print a welcome message to introduce the system. 2. (8 points) Use a loop to prompt the user to enter samples. a. Each sample has a value: CA (in mol A/L) b. If the user enters-1, then it means has entered all samples and the loop should stop prompting user for samples. c. IMPORTANT NOTE: Each successive sample is assumed to be measured with a 1minute interval after the previous sample value. Assume that the first sample is measured at time t=0. 3. (2 points) Prompt the user for the safe concentration threshold for A to be discharged to the waterways. 4. (16 points) Use the same loop above to compute the intermediate variables that you need to hoid all the intermediate results needed to compute a and b. a. IMPORTANT NOTE: You are not allowed to use arrays or vector or any list-based data types to hold the sample values entered by the user. b. Hint: How many intermediate results do you need to keep track of in the loop? 5. (10 points) Design a function to compute r using Equations 2 and 4 and return the value. a. Note: Think about which variables to pass into the function as arguments, and what the function returns. 6. (10 points) Design a function to compute k using Equations 3 and 4 and return the value. a. Note: Think about which variables to pass into the function as arguments, and what the function returns. 7. (7 points) Design a function to compute the time needed for the detoxication to take place before the effluent can be discharged safely (i.e., only after the concentration of A drops below the threshold) and return the value. a. Hint: Since we know CA(t)=kert, we know that t=r1lnkCA(t). All variables on the righthand side will be known at this point. b. Note: Think about which variables to pass into the function as arguments, and what the function returns. 8. (5 points) Use the functions to generate and print out the time required before the effluent can be discharged safely. Timeneededtoreachthresholdfordischarge:18.2974minsThankyouforusingToxicWasteCalculator

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

13. You always should try to make a good first impression.

Answered: 1 week ago