This is what I have so far for my C++ program. I need help with the calculations
ID: 3728416 • Letter: T
Question
This is what I have so far for my C++ program. I need help with the calculations. Can someone please help. Thanks! 7 Budget with Inflation 7. It is difficult to make a budget that spans several years, because prices are not stable. If your company needs 200 pencils per year, you cannot simply use this year's price as the cost of pencils 2 years from now. Because of inflation the cost is likely to be higher than it is today. Write a program to gauge the expected courses/16944/assignments/828257module_item id-543283
Explanation / Answer
Your code is correct except the calculation part so congrats!
For calculation part:
Compound Interest is given by A = P (1 + r) (t)
//Calculation
estimatedcost = costOfItem * ( pow( (1+rateOfInflation), years))
--------------Here is full code-------------
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double costOfItem;
double rateOfInflation;
int years;
double estimatedCost ;
//Take input
cin>>costOfItem>>years>>rateOfInflation;
if(rateOfInflation>1)
{
//If user input 5 then rate will be converted to 0.05
rateOfInflation=double(rateOfInflation/100.0);
}
//Calculation of compound interest A=P(1+r)^t
// pow(a,n) is standard function
estimatedCost = costOfItem * ( pow( (1+rateOfInflation), years));
cout<<estimatedCost;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.