RU beehive logo ITEC dept promo banner
ITEC 120
2008spring
ibarland,
jdymacek

homeinfoarchiveexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs

lab13b
letter distributions
arrays

Practice: In code pad,

We will consider the letter-frequency example from lect13b—arrays:

  1. Review the lecture note's examples on characters and character codes, typing in the examples into code pad.
  2. Enter the code and run it and look it over to understand how it works.
  3. Modify the code so that it doesn't care about the case of the letters -- that is, it counts how many times the letter 'B' appears either as upper- or lower-case. (This actually simplifies the code a little.)
  4. We're about to change the code so that it can process multiple strings in a row. In preparation for this, move the process-one-string code from the constructor to its own method. Otherwise the class should be have exactly as before.
  5. Make a second constructor which takes in any Scanner, and tallies all characters it can read You can ignore whitespace. Test it by evaluating all the characters on this page's html source: new Scanner( new java.net.URL( "http://www.radford.edu/itec120/2007fall-ibarland/Labs/lab14a.html").openStream() ).
    (Of course, you'll also test it using other examples, like the keyboard or a test-file you create. Recall lab10b—greenfoot: wombats: ...and now for something completely different.)
  6. Challenge: Search engines often want to know what language a page is in. One way to determine this is to look at that web page's distribution of letters.

We will not be checking this lab off for regular credit; it is expected that you understand how the array is used to keep track of the character-tally for each letter. If we gave a similar problem, you should be able to write it yourself.

If you do want to check off through step #5 (or more) for extra credit, you can do so in office hours, by the beginning of lab on Dec.05 (Wed).

homeinfoarchiveexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs


©2008, Ian Barland, Radford University
Last modified 2008.Apr.18 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme