Imagine as a finite state machine .... input is received by getchar() State is ---- buffer: up to 10 characters that could be output count: number of characters in buffer badline: set to 1 if bad characters found Before entering loop (and when beginning to process a new line) set badline to 0 set count to 0 Program is a single while loop that use getchar() to read a character Performs test on the character if whitespace and not '\n': Do nothing if alphabetic or digit: if (count >= 10 or badline==1) set badline to 1 else if character is alphabetic translate to range of '2' to '9' add character to buffer at position count increment count if '\n' or EOF if badline == 1 or count != 7 and count != 10 print error message else print buffer in nnn-mmm-pppp format if character is "EOF" exit set count to 0 set badline to 0 otherwise set badline to 1