• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Interest Calculator Output, and loop issues.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic