Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Functional requirements: Your customer is a bank. They would like a program / application that does interest calculations with some console - based user interface.
Functional requirements:
Your customer is a bank. They would like a programapplication that does interest calculations with some consolebased user interface. There are two calculations:
The compounded account value given the principal dollar amount, annual percentage rate APR compounding periods per year, and the number of years. The user interface asks the user for each of the four input values sequentially and prints out the account value at the end of each compounding period for the entire duration. See the example console output below.
What is the principal?
What is the APR?
How many compounding periods are there per year?
How many years will the interest accrue?
For principal APR # of compounding periods per year and number of years :
in years
in years
in years
in years
in years
in years
in years
in years
The time needed to achieve a desired dollar amount given the principal dollar amount, APR, compounding periods per year, and the desired dollar amount. The user interface asks the user for each of the four input values sequentially and prints out the time needed. See the example below.
What is the principal?
What is the APR?
How many compounding periods are there per year?
What is the desired amount?
years are needed
The customer requires any dollar amount and APR in floating point numbers. Compounding periods per year and the number of years are integers.
Background information in compounding interest:
The formula to calculate the value of an investment receiving compound interest is Atprnnt where A is the account value, t is measured in years, P is the initial value of the account called the principal, r is the annual percentage rate APR expressed as a decimal, and n is the number of compounding periods in a year. Let's say the number of years is and the compounding periods per year is Then, the bank pays interest every years months Each time, you add the interest to the principal so that it compounds. Interest is only paid at the end of the compounding period.
Testing requirements:
Having a good understanding of your customers' needs, you sat down with the team member responsible for testing. You agree on the following function names, function input parameters, and function returns.
float calculateaccountvaluefloat principal, float apr, int periodsperyear, float years
This function implements the formula in the background section to calculate the current value of an account given the principal, time, APR, and number of compounding periods per year. The computed current account value should be returned by the function.
void partstd::istream& sin std::ostream& sout
This function is for the user interface. Prompt the user for the necessary values and report the results, as shown below. Input parameters are stringstreams sin and sout. Use sin for prompts and sout for console output. Hint: Do not worry about linking stringstreams to the console output or the keyboard input. That part was implemented for you.
The autograder will look for the specific format provided below. Make sure each prompt is exactly as shown, with a space following the prompt. Make sure you have the correct spelling.
What is the principal?
What is the APR?
How many compounding periods are there per year?
How many years will the interest accrue?
For principal APR # of compounding periods per year and number of years :
in years
in years
in years
in years
in years
in years
in years
in years
float calculaterequiredyearsfloat principal, float apr, int periodsperyear, float desiredamount
This function calculates how much time is required to achieve that desired amount given the principal, APR, number of compounding periods per year, and the final desired amount.
Hint: Time can be in fractional years. Interest is only paid at the end of the compounding period. The return value should equal or exceed the desired amount. The number of years should not be truncated or rounded to an integer.
void partstd::istream& sin std::ostream& sout
This function is for the user interface. Prompt the user for the necessary values and report the results, as shown below. Input parameters are stringstreams sin and sout. Use sin for prompts and sout for console output. Hint: Do not worry about linking stringstreams to the console output or the keyboard input.
The autograder will look for the specific format provided below. Make sure each prompt is exactly as shown, with a space following the prompt. Make sure you have the correct spelling.
What is the principal?
What is the APR?
How many compounding periods are there per year?
What is the desired amount?
years are needed
C
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