Answered step by step
Verified Expert Solution
Link Copied!

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 program/application that does interest calculations with some console-based 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? 1000
What is the APR? 0.1
How many compounding periods are there per year? 2
How many years will the interest accrue? 4
For principal =1000, APR =0.1, # of compounding periods per year =2, and number of years =4:
1050 in 0.5 years
1102.5 in 1 years
1157.62 in 1.5 years
1215.51 in 2 years
1276.28 in 2.5 years
1340.1 in 3 years
1407.1 in 3.5 years
1477.45 in 4 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? 3000
What is the APR? 0.03
How many compounding periods are there per year? 4
What is the desired amount? 4000
9.75 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 A(t)=p(1+r/n)^nt , 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 5, and the compounding periods per year is 4. Then, the bank pays interest every 1/4 years (3 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 calculate_account_value(float principal, float apr, int periods_per_year, 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 part1(std::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 auto-grader 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? 1000
What is the APR? 0.1
How many compounding periods are there per year? 2
How many years will the interest accrue? 4
For principal =1000, APR =0.1, # of compounding periods per year =2, and number of years =4:
1050 in 0.5 years
1102.5 in 1 years
1157.62 in 1.5 years
1215.51 in 2 years
1276.28 in 2.5 years
1340.1 in 3 years
1407.1 in 3.5 years
1477.45 in 4 years
float calculate_required_years(float principal, float apr, int periods_per_year, float desired_amount)
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 part2(std::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 auto-grader 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? 3000
What is the APR? 0.03
How many compounding periods are there per year? 4
What is the desired amount? 4000
9.75 years are needed
C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Organize and support your main points

Answered: 1 week ago

Question

Move smoothly from point to point

Answered: 1 week ago

Question

Outlining Your Speech?

Answered: 1 week ago