Running the program Your program should take 5 arguments: start annual years return inflation where start is the initial investment amount annual is the amount that is added to the investment every year years is the number of years that the investment is held return is the annual investment return expressed as a percentage inflation is the annual inflation rate expressed as a percentage So, to calculate the future and present value of $1000 investment after 10 years where you add $100 every year with a 7% return and 2% inflation, you give the following arguments and get this output: $ ./fv 1000 100 10 7 2 Future Value: $3445.51 Present Value: $2826.52 Writing the code Starter code is provided for you below int main(int arge, char **argv ) { int a, n double value, present, I, is value= atof(argv[1]); a = atoi (argv [2]); natoi (argv[3]); r = atof (argv[4])/100; i = atof(argv[5])/100; // TODO write your code here printf("Future Value: $%.2f\n", value) printf("Present Value: $%.2f\n", present); I have provided code to input the 5 arguments using argy and also code to print the results. Do not change this code. The first three arguments are integers, but the last 2 arguments are floating-point arguments, so that's why I use the double type and the atof function instead of atoi. Remember that the investment return and inflation rates are expressed as percentages - that's the reason for the divide by 100. You will need to write a loop that iterates over the number of years and accumulates the future value. Make sure to add the annual contribution every loop iteration. Note that it is possible to calculate the future and present value with a single equation, but for this problem, you are required to do the calculations using a loop. Do not use any functions from the built-in math library. You will need to create a function to calculate the power function so that you can get the denominator of the present value formula.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question
Running the program
Your program should take 5 arguments: start annual years return inflation
where
start is the initial investment amount
annual is the amount that is added to the investment every year
years is the number of years that the investment is held
return is the annual investment return expressed as a percentage
inflation is the annual inflation rate expressed as a percentage
So, to calculate the future and present value of $1000 investment after 10 years where you
add $100 every year with a 7% return and 2% inflation, you give the following arguments
and get this output:
$ ./fv 1000 100 10 7 2
Future Value: $3445.51
Present Value: $2826.52
Writing the code
Starter code is provided for you below
int main(int arge, char **argv )
{
int a, n
double value, present, I, is
value= atof(argv[1]);
a = atoi (argv [2]);
natoi (argv[3]);
r = atof (argv[4])/100;
i = atof(argv[5])/100;
// TODO write your code here
printf("Future Value: $%.2f\n", value)
printf("Present Value: $%.2f\n", present);
I have provided code to input the 5 arguments using argy and also code to print the results.
Do not change this code. The first three arguments are integers, but the last 2 arguments
are floating-point arguments, so that's why I use the double type and the atof function
instead of atoi. Remember that the investment return and inflation rates are expressed
as percentages - that's the reason for the divide by 100.
You will need to write a loop that iterates over the number of years and accumulates the
future value. Make sure to add the annual contribution every loop iteration. Note that it
is possible to calculate the future and present value with a single equation, but for this
problem, you are required to do the calculations using a loop.
Do not use any functions from the built-in math library. You will need to create a function
to calculate the power function so that you can get the denominator of the present value
formula.
Transcribed Image Text:Running the program Your program should take 5 arguments: start annual years return inflation where start is the initial investment amount annual is the amount that is added to the investment every year years is the number of years that the investment is held return is the annual investment return expressed as a percentage inflation is the annual inflation rate expressed as a percentage So, to calculate the future and present value of $1000 investment after 10 years where you add $100 every year with a 7% return and 2% inflation, you give the following arguments and get this output: $ ./fv 1000 100 10 7 2 Future Value: $3445.51 Present Value: $2826.52 Writing the code Starter code is provided for you below int main(int arge, char **argv ) { int a, n double value, present, I, is value= atof(argv[1]); a = atoi (argv [2]); natoi (argv[3]); r = atof (argv[4])/100; i = atof(argv[5])/100; // TODO write your code here printf("Future Value: $%.2f\n", value) printf("Present Value: $%.2f\n", present); I have provided code to input the 5 arguments using argy and also code to print the results. Do not change this code. The first three arguments are integers, but the last 2 arguments are floating-point arguments, so that's why I use the double type and the atof function instead of atoi. Remember that the investment return and inflation rates are expressed as percentages - that's the reason for the divide by 100. You will need to write a loop that iterates over the number of years and accumulates the future value. Make sure to add the annual contribution every loop iteration. Note that it is possible to calculate the future and present value with a single equation, but for this problem, you are required to do the calculations using a loop. Do not use any functions from the built-in math library. You will need to create a function to calculate the power function so that you can get the denominator of the present value formula.
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L