Write a function declaration for a function that computes interest on a credit

card account balance. The function takes arguments for the initial balance, the monthly

interest rate, and the number of months for which interest must be paid. The value

returned is the interest due. Do not forget to compound the interest-that is, to charge

interest on the interest due. The interest due is added into the balance due, and the

interest for the next month is computed using this larger balance. Use a while-loop that

is similar to (but need not be identical to) the one shown in Display 2.14. Embed the

function in a program that reads the values for the interest rate, initial account balance,

and number of months, then outputs the interest due. Embed your function deļ¬nition

in a program that lets the user compute interest due on a credit account balance. The

program should allow the user to repeat the calculation until the user said he or she

wants to end the program.

I think that what I did is wrong can someone help me out, it compiles but I think the numbers are way off.That aside I think the program is supposed to be done using a while loop, but since i am having doubts with my function im lost, can someone help, I would greatky apreciate it.

This is what is have:

#include <iostream>

using namespace std;

double Calculate (double initial_balance,double rate,int months);

int main()

{

double initial_balance, rate;

int months;

char choice;

do

{

cout << "Please enter your initial balance: ";

cin >> initial_balance;

cout << "Please enter the monthly interest rate(in percent form): ";

cin >> rate;

cout << "Please enter the number of months the bill has ran: ";

cin >> months;

cout << "Interest: $" << (Calculate(initial_balance,rate,months) - initial_balance) << endl;

cout << "Total: $" << Calculate(initial_balance,rate,months) << endl;

cout << " \n Would you like to repeat the calculations? (Press 'Y' or 'y' for yes) "; cin >> choice;

} while(choice=='y'||choice=='Y');

cout << "Farewell!" <<endl;

return 0;

}

double Calculate(double initial_balance, double rate, int months)

{

for (months;months > 0;months--)

{

initial_balance += (initial_balance * (rate/100));

}

return (initial_balance);

}

card account balance. The function takes arguments for the initial balance, the monthly

interest rate, and the number of months for which interest must be paid. The value

returned is the interest due. Do not forget to compound the interest-that is, to charge

interest on the interest due. The interest due is added into the balance due, and the

interest for the next month is computed using this larger balance. Use a while-loop that

is similar to (but need not be identical to) the one shown in Display 2.14. Embed the

function in a program that reads the values for the interest rate, initial account balance,

and number of months, then outputs the interest due. Embed your function deļ¬nition

in a program that lets the user compute interest due on a credit account balance. The

program should allow the user to repeat the calculation until the user said he or she

wants to end the program.

I think that what I did is wrong can someone help me out, it compiles but I think the numbers are way off.That aside I think the program is supposed to be done using a while loop, but since i am having doubts with my function im lost, can someone help, I would greatky apreciate it.

This is what is have:

#include <iostream>

using namespace std;

double Calculate (double initial_balance,double rate,int months);

int main()

{

double initial_balance, rate;

int months;

char choice;

do

{

cout << "Please enter your initial balance: ";

cin >> initial_balance;

cout << "Please enter the monthly interest rate(in percent form): ";

cin >> rate;

cout << "Please enter the number of months the bill has ran: ";

cin >> months;

cout << "Interest: $" << (Calculate(initial_balance,rate,months) - initial_balance) << endl;

cout << "Total: $" << Calculate(initial_balance,rate,months) << endl;

cout << " \n Would you like to repeat the calculations? (Press 'Y' or 'y' for yes) "; cin >> choice;

} while(choice=='y'||choice=='Y');

cout << "Farewell!" <<endl;

return 0;

}

double Calculate(double initial_balance, double rate, int months)

{

for (months;months > 0;months--)

{

initial_balance += (initial_balance * (rate/100));

}

return (initial_balance);

}

Topic archived. No new replies allowed.