Once upon a time there were keyboards attached directly to printers, and they were called typewriters. They didn't require electricity to work, and they were used by people everywhere for about 130 years. They looked like this: [Thanks to Ana Salinas for bringing in her typewriter for me to photograph.]
Pressing a key causes a corresponding "typebar" to rotate upwards to the center, striking the ribbon and leaving an imprint on the paper. These typewriters were an improvement on early typewriters because 1. You could see what was typed, and 2. You had both upper and lower case letters, implemented by "shifting" the typebars upwards so a different part of the type surface hit the paper. (Note our modern keyboards still use the "shift" key to give upper case letters.) Though typewriters are mostly no longer used, some artists such as Keira Rathbone make typewriter art.
Back in 1868 Christopher Sholes patented the typewriter with the QWERTY keyboard, so-called because of the left-to-right order of the top row of letter keys. According to A Brief History of Typewriters, in the early typewriter days during the mid-to-late 1800's there were issues with typebars colliding when people typed quickly. In the above-right picture we can see an example of two typebars colliding when the 'd' is pressed followed quickly by the 'f' key being pressed. As the 'd' typebar returns after striking the paper, the 'f' typebar collides with it as it is heading towards the paper. The Dvorak vs. Qwerty article claims the keyboard layout was instituted in part to slow people down, thus avoiding key bar collisions, and suggests that the layout of keys also helped typewriter salesmen, who could quickly type the word "typewriter" using only the letters on the top row.
In 1932 Professor August Dvorak at Washington State University set out to develop a better keyboard, with more common keys in the home row, with vowels to one side and consonants to the other, to increase the likelihood of hands taking turns, which seemed like it would speed up typing. The article Consider QWERTY indicates that QWERTY was in fact not designed to minimize keybar collisions. It explains the advantages of the DVORAK keyboard as follows:
With the Dvorak keyboard, a typist can type about 400 of the English language's most common words without ever leaving the home row. The comparable figure on QWERTY is 100. The home row letters on Dvorak do a total of 70% of the work. On QWERTY they do only 32%.
One of the fastest typists in the world Barbara Blackburn used a Dvorak keyboard to type 150 wpm for 50 minutes, and was featured on a 1985 Apple IIc ad, which featured a Dvorak/Qwerty switchable keyboard. (Also see Sean Wrona typing 163 words/minute), and test your own typing speed.) On the other hand The Fable of the Keys article indicates the DVORAK layout doesn't do much better than QWERTY.
So which of the keyboard layout claims are true? With contemporary electronic keyboards there is no longer any issue with keybars colliding, and there are very few typewriter salesmen (if any) left, but we still use the QWERTY keyboard layout. Is DVORAK in fact better than QWERTY? The two keyboard layouts [from here] are shown below (click on them to enlarge):
QWERTY:
DVORAK:
Write a program to process an input file called input.txt and display the following output and statistics for both QWERTY and DVORAK keyboard layouts. Upper and lower-case letters are considered the same keyboard position, and so do not need to be treated separately. Any input characters not on the above keyboard maps should be skipped. For the sake of word counts, any white space (space, tab, carriage-return) separates words. Punctuation at the beginning and at the end of a word should not change the statistics for that word. See the (new) sample program readFromFileAndParseWords.c that illustrates how to read from a file into an array of characters. It also processes each line, extracting and printing each word. You can apply your program to the file 20000LeaguesUnderTheSea.txt (from Project Gutenberg). (For reference sake, typing at 60 wpm for 7 hours a day it would take you over 4 days to type the book.)
(5 pts) Echoes the first two lines of the input file
(5 pts) Displays how many words and characters were in the input file
(10 pts) Percent of all letters that can be typed without hands leaving the home row
(10 pts) Percent of words that can be typed without hands leaving the home row
(10 pts) Percent of words that can be typed on the same hand
(15 pts) Total distance travelled by fingers (in miles, to 3 decimal places), assuming:
In the home row typing a middle key is moving .75 of an inch (e.g. type 'g' or 'h' on a QWERTY keyboard)
Each time a finger leaves the home position for the row immediately above or below, that is moving .75 of an inch, with the following exceptions:
'T' and 'Y' are each 1 inch. 'B' is 1.25 inches.
Each time a finger leaves the home row for the top (numbers) row, that is moving 1.5 inches, with the exception that '6' and '^' are 1.75 inches.
The measurements described in this assignment assume that you are "touch-typing", using all ten fingers. The "home row" is the middle row, where your 8 fingers should start. Output should look something like the following, although the results below are completely made up:
Author: Dale Reed
Class: UIC CS 141, Fall 2016, Program2
Lab: 7am Tues
First two lines of the input file are:
TWENTY THOUSAND LEAGUES UNDER THE SEA
by JULES VERNE
Total words: 4326
Total non-blank characters: 32098
Qwerty Dvorak
% All Characters on home row: 3 40
% All Words on home row: 25 43
% Words typed on one hand: 17 13
Distance travelled(miles): 1.583 0.796
Turn in your program using Blackboard. Multiple submissions are allowed, but only the most recent submission will be graded.
The name of the program you will turn in should be prog2 followed by your netid and the .c file extension. In other words, if your netid is reed then your program would be called prog2reed.c
You must also zip up the file you turn in, which typically is done by right-clicking on it and choosing the "compress" option. After zipping your program (e.g. prog2reed.c), you will likely end up with a file called something like prog2reed.zip. Only turn in this single file, turning it in on Blackboard into the assignment Program 2. Please do not put it into a folder before zipping it, rather zip the one file by itself.
Failing to follow these naming conventions and failure to turn in a zip file will result in a 5 point deduction, even if everything else is perfect in your program.