UW CSE logo uw

CSE 142: Computer Programming I, Summer 2008

arrow CSE Home arrow About Us arrow Search arrow Contact Info

Homework 7 (Personality Test) FAQ

Q: Where do I start?

A: Try to break the problem into pieces. First try to read a record (a name and 70 answers) from the file. Then try to count the As and Bs. Look at the diagram on the last page of the handout for inspiration. If you aren't very familiar with arrays, perhaps try looking at practice problems about them first until you feel comfortable.

Q: How do I examine the letters of the line to see whether they are A or B?

A: Look at section 4.4 in the text book and look over section 7 problems about text processing. The String class's charAt method is useful.

Q: How do I place the A or B into the right element of the array, when counting As and Bs?

A: There is a repeating pattern. Look at the lecture example on section attendance. It's okay to use if/else statements to express the mapping between the characters and the array indexes, as long as you avoid redundancy as much as possible.

Q: How do I output to a file? How does PrintStream work?

A: After you've constructed it, a PrintStream works just like System.out. Look in Chapter 6 section 6.4, or the Sections lecture program.

Valid XHTML 1.1 Valid CSS!