UW CSE logo uw

CSE 142: Computer Programming I, Summer 2008

arrow CSE Home arrow About Us arrow Search arrow Contact Info

Homework 6 (Baby Names) FAQ

Q: How do I get started?

A: Read Ch. 6 in the textbook. Look over the IMDB movie example from lecture.

Q: How do I make my code work for the 0 case?

A: The 0 ranking case is one of the hardest parts of the assignment. We recommend getting everything else to work first before worrying about the 0 case. You'll need to insert code to handle 0 differently than other rankings. One hint: A ranking of 0 is really more like a ranking of 1000, so it may help you to treat it that way in parts of your code.

Make sure to avoid redundant code. If you're doing the same thing in many branches of an if/else, that's redundant. It will make your code harder to write and more likely to have bugs.

Q: Why do I get a NoSuchElementException?

A: You tried to read past the end of a Scanner. Read the exception output text carefully and look for the first line that mentions your program. That's the line that is the culprit. For example, the output:

Exception in thread "main" java.util.NoSuchElementException
          at java.util.Scanner.throwFor(Scanner.java:838)
          at java.util.Scanner.next(Scanner.java:1347)
          at BabyNames.sillyMethod(BabyNames.java:39)
          at BabyNames.main(BabyNames.java:15)

means that there's an error in sillyMethod at line 39 of BabyNames.java.

Q: Why do I get an InputMismatchException?

A: You tried to read the wrong type of token from a Scanner. For example, you tried to read the word "Lisa" as an int.

Q: How do I make a Scanner start over or go back?

A: You can't! But if it is a String Scanner, you can make a new Scanner over the same String to start reading over again.

Q: Why are my coordinates wrong? How can I fix them?

A: Try using the debugger or println statements to see what they are.

Valid XHTML 1.1 Valid CSS!