Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Writing a loop to determine total savings

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 09-12-2013, 02:39 AM PM User | #1 Daren_Z New to the CF scene   Join Date: Sep 2013 Location: Edmonton Posts: 7 Thanks: 3 Thanked 0 Times in 0 Posts Writing a loop to determine total savings Hello, My girlfriend asked me to write a loop to determine the total amount she will save if she starts by putting in \$75 and puts in 1 more dollar every week (75, 76, 77, ... 127). Right now, I'm stuck at trying to get the for loop to add the extra dollar every week. Here is what I have so far Code: ```int save = 75; for(int i = 1; i<=54; i++){ int deposit = save+i; int sum = save + deposit; System.out.println("week " + i + ". Please deposit: " + deposit + " dollars"); System.out.println("You have " + sum + " dollars in the bank"); }```
 09-12-2013, 12:54 PM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,595 Thanks: 4 Thanked 2,597 Times in 2,566 Posts I'm not sure if you're running total is referring to the summed saving or to the amount to deposit. Given the result of deposit, I'd suspect that's to be deposit. You'd need to move the sum before the loop and initialize it to save, then add deposit to it within the loop. Simple as that. __________________ PHP Code: ``` header('HTTP/1.1 420 Enhance Your Calm');  ```
 Users who have thanked Fou-Lu for this post: Daren_Z (09-13-2013)
 09-12-2013, 01:29 PM PM User | #3 Roelf Senior Coder   Join Date: Jun 2002 Location: Zwolle, The Netherlands Posts: 1,120 Thanks: 2 Thanked 31 Times in 31 Posts Funny, this is the sort of question a teacher would ask, not a girlfriend.... __________________ I am the luckiest man in the world
 09-13-2013, 10:11 PM PM User | #4 Daren_Z New to the CF scene   Join Date: Sep 2013 Location: Edmonton Posts: 7 Thanks: 3 Thanked 0 Times in 0 Posts Yeah, she's trying a new way to save, so since I'm alright at math she asked me how much she would save. And I thought it would make some good practice since I haven't touched java in almost a year. Thanks Fou-lu, I'll try making that change to the code and see how it turns out.

 Bookmarks

 Tags for loop, java, money, savings

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 06:05 AM.