
January 27th, 2013, 10:16 AM
|
Registered User
|
|
Join Date: Jun 2012
Posts: 22
Time spent in forums: 9 h 6 m 36 sec
Reputation Power: 0
|
|
Would i did was just moved the
Code:
newest = (price = price*1.056);
into the while statement at the bottom so it would execute every time the year increased.
Code:
#include <iostream>
using namespace std;
int main()
{
double pencils, price, years;
cout << "How many pencils will you be needing?\n";
cin >> pencils;
cout << "How much did that cost you this year.\n";
cin >> price;
cout << "So thats " << (price/pencils) << " each pencil.\n";
cout << "How many years would you like to know the price in advance?\n";
cin >> years;
cout << "With that said your can expect the following prices for the next " << years << " years with 5.6 percent interest.\n ";
double newest;
while (years > 0)
{
newest = (price = price*1.056);
years = years - 1;
cout << newest << "\n";
}
cout << endl;
return 0;
}
|