Win a copy of High Performance Python for Data Analytics this week in the Python forum!

Larry Robinson

Greenhorn
+ Follow
since Oct 10, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Larry Robinson




next
public String next(Pattern pattern)
Returns the next token if it matches the specified pattern. This method may block while waiting for input to scan, even if a previous invocation of hasNext(Pattern) returned true. If the match is successful, the scanner advances past the input that matched the pattern.
Parameters:
pattern - the pattern to scan for
Returns:
the next token
public String nextLine()
Advances this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line, excluding any line separator at the end. The position is set to the beginning of the next line.
Since this method continues to search through the input looking for a line separator, it may buffer all of the input searching for the line to skip if no line separators are present.
Returns:
the line that was skipped

Here is the program that you started with and a few changes. First I always just import the whole java.util or any of the others. That way when I am working I do not have to go back and add another sector of the class. I also set the decision at the bottom as well as the request for a decision. I also cleared the variable “fullname” after it's use, at the bottom. I changed some of the variables it is best to be descriptive so, it is easy to read. Oh! I also setup the decision from ZZZZ to Y/N so that next() would work. As you can see from above next() returns a token; one character in this case. As you can read from above the nextLine() searches till reads a line separator so there needs to be a line separator added to your variable or else you will only be able to use the name input first time around. I could not find a way around this with the limitations you have on your assignment. There are lots of ways of doing it a lot easier but not within the scope of your assignment.
Take care and remember there is no such thing as Luck just hard work and good thoughts.



I hope this helps you. Make your logic flow from one section to the other. In my other post I to had some logic mistakes.
11 years ago
Correct me if I am wrong but, it seems to me that everyone is looking at code when they should be looking at logic.
Here is how I see the problem: You need to do until right, when right then do something else and go to the next section. Using this manner of logic you then know that the inputer will not get to go anywhere till it is right and when it is right that will be recorded. This then leads to the choice of loops, the do while seems to be the only choice. Bring them in and do not let them out till they get it right. Being you are just learning do not worry about exceptions or full names. To start with just use one name and let the name be anything as long as you convert it to characters ie b2b anything but ZZZZ. Once you get that going you can test for more things even adding the full name.
To use full names you will need to do as said above, sorry who every said it for not relooking, use nextLine() this works for when there might be spaces.
11 years ago
It seems to me that you are forgetting the main principle behind java, Make each part work. You can take the main then one part and make it work when you are done with it start the next part and make it work, of course with the first part.
Hopefully I am not insulting here. Just trying to help. I to will copy it and see if I can be more help
I would say "Good luck" but there is no such thing just hard work and good beliefs.
11 years ago