• Post Reply Bookmark Topic Watch Topic
  • New Topic

Restart loop  RSS feed

 
Danny Takeda
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone, my last post was not coded for easier reading so i am reposting the code. The issue that i am having is that at the bottom of the code i cannot seem to get my restart portion to function properly. When i type no the program exits but when i type yes the program still exits. Any advice would be appreciated, thank you so much.

Danny
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i type no the program exits but when i type yes the program still exits.

Where is the loop that controls the restarting of the code?  After reading the user's input and printing a message, there is no logic for the program to loop back.
 
Ganesh Patekar
Bartender
Posts: 696
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • I think first you need to create separate methods for input, calculation and to display calculation of commisssion for that you wrote bunch of print statements.
  • See If you create a method to print commision like below Or using different logic, which removes all your print statements from main method which starts from line no 103 to 131.

  • You don't need to cast on line no 77 where all variables are already double.

  • IMO you should not proceed to add anything to this code until you separate code into appropriate methods.
    You better read Main Is A Pain
     
    Fred Kleinschmidt
    Bartender
    Posts: 560
    9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You are doing way too much in the main() function. You should refactor it into something like:


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