this is what I have so far, if you run it you\'ll see that it gives you at 1 sec
ID: 3689605 • Letter: T
Question
this is what I have so far, if you run it you'll see that it gives you at 1 seconds the tank has 492.5 gallons. however, I need it to run 1-5 seconds /* Determine at which time the tank will be empty*/ #include<iostream> using namespace std; int main() { /* declare variables*/ double totalgallons(495), pipeA(5), pipeB(10), pipeC(2.5), pipeD(7.5), pipeE(20); cout << "time, s gallons, g "; /*time intervals*/ int time[6] = {}; for (int r = 5; r <= 5; r + 5) { if (r <= 5) { pipeA = 25; pipeB = 25; pipeC = 0; pipeD = 37.5; pipeE = 100; time[r] = r; totalgallons = totalgallons + pipeA + pipeB + pipeC + pipeD - pipeE; cout << time[r] << " " << totalgallons << endl; } } }
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
/* declare variables*/
double totalgallons=495, pipeA=5, pipeB=10, pipeC=2.5, pipeD=7.5, pipeE=20;
cout << "time, s gallons, g ";
/*time intervals*/
int time[6] = {};
for (int r = 1; r <= 5; r++)
{
if (r <= 5)
{
pipeA = 25;
pipeB = 25;
pipeC = 0;
pipeD = 37.5;
pipeE = 100;
time[r] = r;
totalgallons = totalgallons + pipeA + pipeB + pipeC + pipeD - pipeE;
cout << time[r] << " " << totalgallons << endl;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.