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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started