C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 24th, 2013, 03:49 PM
nbkxjosh nbkxjosh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 nbkxjosh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 49 sec
Reputation Power: 0
General - Basic question im just new

i need this to out put the amount of years the person wants so basiclly if they put 50 year one should be 52.8 year after that should be 52.8 times 1.056 to increase it even more but i cant make it work









#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;
newest = (price = price*1.056);

while (years > 0)
{
years = years - 1;
cout << newest << "\n";
}
cout << endl;

return 0;
}

Reply With Quote
  #2  
Old January 27th, 2013, 10:16 AM
Dyrand Dyrand is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 22 Dyrand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Basic question im just new


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap