Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interest Calculator Output, and loop issues.  RSS feed

 
Clarence Poma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel like an idiot. I'm having 2 issues with the code below.

If the user inputs "n", rather than taking them back to the start and prompting for the numbers again, if simply repeats "Please provide the information again" in an endless loop.

The second issues, is the final lines. It outputs fine...however, it is not adding/updating the balances for each quarter.



The sample output is:



So, the first line/quarter is fine, but the following lines are not calculating properly.
I've spent 4 hours on this, and am completely stumped.
Thank you.
 
Clarence Poma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, I've solved the second problem with the calculations, however I'm still experiencing the issue with the program not going back to the beginning and prompting the users to enter data
 
Carey Brown
Bartender
Posts: 2994
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need an outer loop to start over.

You have too much code in your main() method. You need to refactor it into multiple methods where each method performs a single task and the method's name clearly indicates the purpose of the method.
 
Carey Brown
Bartender
Posts: 2994
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code should look this simple. See how the method names are obvious. See how it's uncluttered and concise.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!