| CS 311 Spring 2008 > Assignment 8 |
Assignment 8 is due at 5 p.m. Friday, May 2. It is worth 20 points.
E-mail answers to the exercises below to ffggc@uaf.edu, using the subject “DA8”.
In this exercise, you will write a complete program that uses a C++ STL Table implementation.
Write a C++ program that stores a collection of name/ID-number pairs, as described below. Be sure to follow the coding standards. All standards now apply!
When the program is run, a brief message is printed, and then pairs of names and ID numbers are entered by the user. Input is terminated with a blank line. Then the user may enter a series of names. The program checks the previously entered list of pairs. If the name is present, the corresponding ID number is printed; otherwise, a message is printed, indicating that the name was not found.
The source code for your program should be turned in as the single file “nameid.cpp”.
Here is a sample run:
Name-ID
By Smurgle Smorkoblix
1 May 2008
CS 311 Spring 2008 - Assignment 8, Exercise A
Phase 1: Enter ID list entries (name & ID #).
Blanks line ends input.
Enter name: Zephaniah Smith
Enter ID #: 23
Enter name: Hercules
Enter ID #: 6
Enter name: Hercules
Enter ID #: 0
Enter name:
Phase 2: Enter names.
For each name, the corresponding ID will be printed,
if the name is in the ID list.
Blank line ends input.
Enter name: Gorgo
(Name not found)
Enter name: Hercules
ID # = 0
Enter name: Gorgo
(Name not found)
Enter name: Zephaniah
(Name not found)
Enter name: Zephaniah Smith
ID # = 23
Enter name:
Exiting ...
Additional requirements:
Hints:
is not appropriate here, since this reads up to the next blank, not to the end of the line. Instead, you probably want to do something likecin >> value;
std::getline(cin, myString);
| CS 311 Spring 2008: Assignment 8 / Updated: 28 Apr 2008 / Glenn G. Chappell / ffggc@uaf.edu |
|