CSCI 333 Project 3

This assignment is due Friday, 7 November, 2003 at 11:00 am.

The task

Write a program that processes lines one of the following two forms, where VARNAME is an "identifier" name composed of 1 to 7 lowercase letters and POSINT is a positive integer between 0 and 999.

The intent of the first statement, the one with the = operator is to initialize a variable. If the variable has previously been initialized, this statement should be considered an error. The intent of the second statement, the one with the += operator is to increase that value stored variable. If the variable has previously not been initialized, this statement should be considered an error. An arbitrary number of spaces is allowed before and after the variable names and positive integers.

For this assignment, "process" means merely to read the lines, check if they are in the proper format, and print out a neatly structured table of all the legal statements. Illegal statements may be ignored.

For the following input

   abcd   =  15
 abcd   +=  13
  toobig  = 2003
 NOCAPS = 333
 no space = 300
 noneg = -15
 %$#^$@& this is a really bad line
  muchtoolong = 3
   notinit += 17
sogood=999
 abcde  = 400
sogood+=800
  let's end this thing now

The output of the program should be something like:

abcd     =  15
abcd    +=  13
sogood   = 999
abcde    = 400
sogood  += 800

Turning in the assignment

You will turn in your exercise by storing your C++ code in a file Project3.cpp stored within a read-protected subdirectory csci/333/Project3 of your UNCA CSCI Unix account. Here are the commands for creating and read-protecting this directory: