Where is the infinte loop happening? In what method in what class?
Add some println statements that shows the execution flow so you can see where the code is executing and where the loop is.
For solid code and better bug detection you should add a default case to the switch and have it print out the value of selection to see if there is a problem there.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What prints out from the println statements that you added? The printed output should show you where the code is executing.
Is the program looping or is it waiting for input from the user? Type in a number.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
So now you know what the program is doing: its waiting for you to enter a number. Look at the code in the Menu class and see where there is code trying to read from the user. Hint: the Scanner class has methods for reading from the user.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
my switch(selection) is not functioning properly
What did the println in the default: case print out for the value of the variable: selection?
You should not comment out the default case. It should not execute unless there is a problem which you want to know about.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
You need to print out the value of selection so you know what the computer saw when it executed the switch statement.
System.out.println("Error: Unrecognized selection="+selection); // show value with message
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Question Answered as of 8 Months Ago by
NormR1 Glad you found it. The char '1' is not the same as an int with the value of 1.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16