Question

Hello I need C++ Code For the Following:

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 definition 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 says he or she wants to end the program.

Other Requirements:

The function needs to return interest accrued, not balance.

For the main, should ask for the annual percentage rate in terms of %.

Below is an example showing the accumulation of interest with an initial balance of $100 and a 12% annual rate:

b. balance $100.00 101.00 $102.01 $103.03 $104.06 $105.10 int rate num. Months one month int $1.00 12.00% $1.01 12.00% $1.02 12.00% 12.00% $1.03 $1.04 12.00% $1.05 12.00% end balance $101.00 $102.01 $103.03 $104.06 105.10 $106.15 accrued int $1.00 $2.01 $3.03 $4.06 $5.10 $6.15

Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1


/**
C++ program that prompts user to enter balance,rate
and number of months and then display a table
formatted with interest earned for given number of months.
*/
//header files
#include<iostream>
#include<iomanip>
using namespace std;
//function prototype
double getInterest(double balance,double rate);
int main()
{

   //declareation of variables
   double balance=0;
   double rate;
   int numMonths;
   double totalInterest=0;
   double interest;
   double endBalance;

   //prompt for balance
   cout<<"\tEnter principle amount : ";
   cin>>balance;
   //prompt for rate
   cout<<"\tEnter rate of interest : ";
   cin>>rate;
   //prompt for num months
   cout<<"\tEnter number of months : ";
   cin>>numMonths;

   cout<<fixed<<setprecision(2);

   //calculate monthly interest rate
   double monthInt=((rate/100.0)/12.0);


   cout<<"balance"
       <<setw(5)<<"int rate"
       <<setw(5)<<"num. Months"
       <<"$"<<"one month int"
       <<"$"<<"end balance"
       <<"$"<<"accured int"<<endl;

   for(int m=1;m<=12;m++)
   {
       //calling getInterest method that returns interest on balance with monht interest
       interest=getInterest(balance,monthInt);
       //add balance and interest and ste to endBl
       endBalance=balance+interest;
       totalInterest+=interest;

       cout<<"$"<<balance
           <<setw(8)<<rate<<"%"
           <<setw(5)<<m
           <<setw(5)<<"$"<<interest
           <<setw(8)<<"$"<<endBalance
           <<setw(8)<<"$"<<totalInterest<<endl;

       //set end balance to balance
       balance=endBalance;
       //reset interest to 0
       interest=0;
   }

   system("pause");
   return 0;
}

/*
The method getInterest that takes balance and rate
and returnst the interest on balance
*/
double getInterest(double balance,double rate)
{
   double mInterest=0;
   mInterest=balance*rate;
   return mInterest;
}

Sample Output:

Enter principle amount Enter rate of interest Enter number of months 100 12 12 balanceint ratenum $108.00 12.00% $101.00 12.0

Add a comment
Know the answer?
Add Answer to:
Hello I need C++ Code For the Following: Write a function declaration for a function that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • i need this to be in OOP using C++ 25. Savings Account Balance Write a program...

    i need this to be in OOP using C++ 25. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three-month feried. It should ask the user for the starting balance and the annual interest rate. A loop abculd then iterate once for every month in the period, performing the following steps: B) A) Ask the user for the total amount deposited into the account during that month and add it...

  • C++ 18. Savings Account Balance Write a program that calculates the balance of a savings account...

    C++ 18. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following A) Ask the user for the total amount deposited into the account during that month. Do not accept negative numbers. This amount should be added to the...

  • I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instruction...

    I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...

  • This C++ Program should be written in visual studio 2017 You are to write a program...

    This C++ Program should be written in visual studio 2017 You are to write a program that can do two things: it will help users see how long it will take to achieve a certain investment goal given an annual investment amount and an annual rate of return; also, it will help them see how long it will take to pay off a loan given a principal amount, an annual payment amount and an annual interest rate. When the user...

  • I need only one  C++ function . It's C++ don't write any other language. Hello I need...

    I need only one  C++ function . It's C++ don't write any other language. Hello I need unzip function here is my zip function below. So I need the opposite function unzip. Instructions: The next tools you will build come in a pair, because one (zip) is a file compression tool, and the other (unzip) is a file decompression tool. The type of compression used here is a simple form of compression called run-length encoding (RLE). RLE is quite simple: when...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • Using basic c++ write a separate code for each of the following: 1. Area Rectangle •...

    Using basic c++ write a separate code for each of the following: 1. Area Rectangle • Write a program that asks the user to enter length and width of a rectangle and then display the rectangles area. • Write the following functions • getLength – prompt the user to enter length and return that value as a double • getWidth – prompt the user to enter width and return that value as a double • getArea – This method should...

  • Using the Design Recipe, write an algorithm for each of the following programming problems, showing all...

    Using the Design Recipe, write an algorithm for each of the following programming problems, showing all work (i.e., Contract, Purpose Statement, Examples and Algorithm): 5.Write a program that reads two times in military format (e.g., 0900, 1730) and prints the number of hours and minutes between the two times. Note that the first time can come before or after the second time. 6.An online bank wants you to create a program that shows prospective customers how their deposits will grow....

  • the programing language is C++ TIC PEO. Design a generic class to hold the following information...

    the programing language is C++ TIC PEO. Design a generic class to hold the following information about a bank account! Balance Number of deposits this month Number of withdrawals Annual interest rate Monthly service charges The class should have the following member functions: Constructor: Accepts arguments for the balance and annual interest rate. deposit: A virtual function that accepts an argument for the amount of the deposit. The function should add the argument to the account balance. It should also...

  • (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account...

    (C++) How do I develop a polymorphic banking program using an already existing Bank-Account hierarchy? For each account in the vector, allow the user to specify an amount of money to withdraw from the Bank-Account using member function debit and an amount of money to deposit into the Bank-Account using member function credit. As you process each Bank-Account, determine its type. If a Bank-Account is a Savings, calculate the amount of interest owed to the Bank-Account using member function calculateInterest,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT