Question: C++ Complete ComputeSavings()'s recursive case: If month is odd, call ComputeSavings() to compute the next month's savings as the current month's savings plus 18. Otherwise,
C++
Complete ComputeSavings()'s recursive case:
If month is odd, call ComputeSavings() to compute the next month's savings as the current month's savings plus 18.
Otherwise, call ComputeSavings() to compute the next month's savings as the current month's savings plus 6.
Ex: If the input is 5 143, then the output is:
Month: 5, savings: 191
#include
void ComputeSavings(int totalMonth, int month, int savings) { if (month == totalMonth) { cout << "Month: " << month << ", savings: " << savings << endl; } else {
/* Your code goes here */
} }
int main() { int totalMonth; int savings; cin >> totalMonth; cin >> savings; ComputeSavings(totalMonth, 1, savings); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
