please I need help Quickly

A dark mage casted a black spell On the fountain of life.So,instead of producing the elixir of life,the fountain now produces the elixir of life and the dark poison at rate r (litet/sec). the fountain will become deadly when the amount of poison is the as that of elixir in the fountain.

Write a C++ program that input the initial volume of elixir in the fountian before the spell was costed ,the rate of elixir production (e liters/sec),and the rate of poison production (r),It should output the time,t in second when the mixture becomes deadly.
Note (cannot use while loop)

please help me
Solve this mathematically using pen and paper, then translate final formula in c++.
can you give me an example?!
Ask any middle schooler.

Well, lets take
a — for initial amount of elixir;
e — amount of elixir generated per second;
r — amount of poison generated per second;
t — seconds passed.
Total amount of elixir after t seconds will be a + e*t;
Amount of poison: r*t

We need to find when amount of elixir equals amount of poison, so final equation will be: a + e*t = r*t.
Solve for t
Last edited on
Is this right ?

using namespace std;
int main ()
double a,e,r,t,Total;
cout<<"Input the Initial Volume of Elixir & the rate of poison production: ";
cout<<"The Time Mixture become deadly"<<t<<endl;
return 0;

Solve an equation for t before writing any code. It's an middle school program after all.
Last edited on
i solved it
??? write
so, now take initial amount of exlixir (a), elixir generation rate (e) and poison generation rate (r) from user and do:
double t = a/(r-e);
Last edited on
using namespace std;
int main ()
double a,e,r;//a=initial liters of elixir,e= elixir produce liters/sec,r= poison produce liters/sec
double t;//time in second
cout<<"Inputs Initial Volume of Elixir & Rate of Elixir in liters/sec & Rate of poison in liters/sec: ";
cout<<"Mixture become deadly at t="<<t<<" sec"<<endl;
return 0;

i think this true

and thank you very-much dear ...
Topic archived. No new replies allowed.