CPTR246 Spring '99 (100 total points) Exam 1
int x(10);
int * a;
a = &x;
*a = *a * x;
cout << x << endl;
Structures: (20 points)
Student name (a string of at most 30 characters)
Number of courses this semester
At most 6 course numbers (each an integer)
messagesThisMonth - right justified
moneyOwed - right justified, fixed decimal, two decimal points
The AddressBook can hold up to 50 addresses, but may have less. The integer object numberOfEntries holds the number of addresses actually in AddressBook. Below are the object definitions and a sample call to the function.
struct Address {
Address AddressBook[50]; // address book
int numberOfEntries; // number of entries
. . . . // Address book gets loaded with data
// sample call to the function
printAddressBook(AddressBook,
numberOfEntries);
Parsing input: (25 points) A file has been created that contains employee information, specifically employee ID (an integer), full name (a string), and this week's calculated pay (a real number). The file is formatted so that the information for each employee is on one line and the values are separated by pound signs (#). For example, the file might contain:
987654321#Mary Q. Public#500.00#
1212121#Sam Smith#620.10#
. . . .
An example of the function's use:
int ID;
char name[30];
double pay;
ifstream inFile("weekly.dat");
. . .
// sample call to function
getNextEmployee(inFile, ID,
name, pay);
. . . // ID, name, and pay are used in later code