A fixed percentage of water is taken out from a tank each day. Write a program, Tank.cpp, that
accepts as input:
W, representing the amount of water in the tank at the start of the first day
P, representing the fixed percentage of water taken out of the tank each day
and, starting from the first day, displays the number of the day, the amount of water taken out for
that day, and the amount of water remaining in the tank at the end of that day. Your program should
terminate after 30 days have been displayed or when the amount of water remaining is less than
100 units, whichever comes first.
1
Expert's answer
2019-10-21T15:31:39-0400
void Tank(double W, double P)
{
int i =1;
do
{
cout << "Number day: "<< i++ <<". Water taken: " << W*P/100 << ". Water remaining: "<< W*(100-P)/100 << endl;
W*=(100-P)/100;
} while (W >=100 && i <31);
}
Comments
Leave a comment