Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote