CPE 103 Lab Activity
Sets
Overview
Do you know the reason for the arrangement of letters on a standard keyboard?
The Dvorak keyboard is argued to be a vastly more comfortable and
efficient alternative to the standard "QWERTY" pattern, because the
most commonly occurring letters in English appear on the home row.
Assignment
Write a program using Sets to read a file of English text and count the
number of characters that appear on each of the three rows of both
style keyboards. Consider only alphabetic characters, not numbers
or punctuation. The name of the file will be provided on the
command line. Follow the examples in the command
line tutorial.
Instructions
- Compute by hand the results for QWERTY and Dvorak
using this sample sentence: "amazingly few discotheques provide jukeboxes".
- Write a Java program to meet the requirements above. You should use Sets and Lookup tables effectively
in your solution.
- Avoid brute force solutions. (A chain of six if statements is not acceptable).
-
The output should appear something like this:
|
QWERTY
|
|
Dvorak
|
|
|
count
|
%
|
count |
%
|
Top row
|
200
|
40
|
100
|
20
|
Home row
|
200
|
40
|
300
|
60
|
Bottom row
|
100
|
20
|
100
|
20
|
Total
|
500
|
|
500
|
|
(Consider printf for column alignment.)
- Test your program using the sample sentence and
verify that the results match your manually calculated answers.
- Once your program passes your tests, run it on the
complete
text of "The Adventures of Huckleberry Finn" by Mark Twain.
If you finish during the lab hour show your results to the instructor
so they can be checked for correctness.
Record the results in a comment in the header of your source code.
- JUnit tests are recommended but not required on this lab.
- You must submit execution output with the sample sentence
and with Huckleberry Finn.