CSC 161 Module on Working with Characters, Strings, and I/O
Introduction
This module introduces CSC 161 students to writing dynamic programs that
can take input and follow commands based on input, including
- characters
- strings
- input and output.
Day-by-day Details
Day
| Topic
| Preparation
| In-class
| Due Date
| Availability for Extra Credit
|
Friday, February 27
| Module 011: Strings and I/O
|
| Examples
|
|
|
Monday, March 2
| Characters and Strings
| Reading from Text
- King: Section 7.3, Chapter 13, pages 134-141, 277-299, OR
- Kernighan & Ritchie: 1.9, 7.8.1, 7.8.2, B.3
| Characters
and Strings Lab
|
|
|
Tuesday, March 3
| Reading data values with scanf
|
- Reading from Text
- King: Section 3.2, pages 42-46, OR
- Kernighan & Ritchie, 7.4
B.1.2, B.1.4 (reference)
- Notes on Reading Data
- Examples:
| Lab on Input with scanf
|
|
|
Wednesday, March 4
| Charactger-by-Character Input and Output
|
- Reading from Text
- King: Section 3.1, pages 37-41 OR
- Kernighan & Ritchie: 1.5, 7.1, 7.2, B.2 (reference)
- Examples:
| Lab on
Character-by-Character Input
| Wednesday, March 10
|
|
Friday, March 6
| Hour Test 1
| Covers through Lab on Input with scanf
|
|
|
Monday, March 9
| Project
|
| Robot follows typed commands
| Wednesday, October 29
|
|
Project: Robot Follows Typed Commands
Working in pairs, students should develop a program that includes these
elements:
-
program controls actions and sounds in the robot
-
program prints a prompt that lists the possible actions
-
robot can perform at least ten different commands
-
the command to quit may be counted as one of these ten different
commands
-
each action (except, perhaps, the command to quit) must be
implemented as a separate procedure
-
at least five of the procedures should utilize parameters in a
substantive way; if user values are requested, the input/output
should be handled in the main procedure and values passed to the
procedure controlling the action
-
at least two actions should be blocking and at least two actions
should be non-blocking
-
robot counts the number of actions taken and prints the number of actions
taken at the end of the program
-
program ends only after the user types a command to quit
Together with the program, a student pair must write a paragraph that
describes what tests are needed to demonstrate the program is working
correctly. That is, what should a tester do to demonstrate the program
works? Also, the student pair must present a sequence of steps
that the tester should do to carry out the test plan. (E.g., what should
be typed in a terminal window, including the details of the compile,
link, and run steps?)
Command Requirements
- Commands should be words, not letters.
- Each command must perform a clearly different action. The same
action, but with different duration or speed does not count as a
different action.
Allowed: turnLeft, turnRight
Not Allowed: turnLeft1second, turnLeft2seconds
- At least 5 commands must also take one or more parameters, entered in
the main program and passed to the function executing the command. For
example, if you implement the beep function, the user must be able to
specify the duration and pitch of the beep. If you implement a short
dance, the user may not need to specify the length of any of the dance
steps.
Grading
Note
This project is planned for use as the base of a later project, so you will
want to document your code well now — in anticipation of later
activities.