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)
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
#include<iostream>
using namespace std;
int main ()
{
double a,e,r,t,Total;
cout<<"Input the Initial Volume of Elixir & the rate of poison production: ";
cin>>a;
e=a+e*t;
r=r*t;
t=a/(r-e);
if(e=r)
cout<<"The Time Mixture become deadly"<<t<<endl;
system("pause");
return 0;
}
#include<iostream>
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: ";
cin>>a>>e>>r;
t=(a)/(e-r);
cout<<"Mixture become deadly at t="<<t<<" sec"<<endl;
system("pause");
return 0;
}