#include #include int main() { double cost, infl; int years,i; char buffer[50]; std::cout << "Current cost of a pencil: "; std::cin >> cost; std::cout << "Inflation percentage: "; std::cin >> infl; infl /= 100; std::cout << "Years to calculate: "; std::cin >> years; for (i = 1; i <= years; i++) { cost += (infl * cost); } sprintf(buffer,"%.2f",cost); std::cout << "Cost of one pencil in " << years << " years will be: $" << buffer << "\n"; }