Question: Complete GetDecay()'s recursive case: If weight 60.0, call GetDecay() to compute the next day's weight as the current day's weight multiplied by 0.5. Otherwise, call
Complete GetDecay()'s recursive case:
If weight 60.0, call GetDecay() to compute the next day's weight as the current day's weight multiplied by 0.5.
Otherwise, call GetDecay() to compute the next day's weight as the current day's weight multiplied by 0.9.
Ex: If the input is 50.0, then the output is:
day: 1, weight: 50.0 day: 2, weight: 25.0 day: 3, weight: 12.5 Finished
#include
void GetDecay(int day, double weight) { cout << fixed << setprecision(1) << "day: " << day << ", weight: " << weight << endl; if (day == 3) { cout << "Finished" << endl; } else {
/* Your code goes here */
} }
int main() { double weight; cin >> weight; GetDecay(1, weight); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
