Assignment 7


20 points
Due: May 1st at 11:59pm

The objective of this assignment is to create and use exception handling using user defined objects. You are to create a class for this assignment and throw objects of the created class.

You are to write a C++ input program to read and verify keyboard input using these very stringent restrictions. The user will enter space delimited data and you are to determine whether each item is a valid identifier, valid integer, or valid decimal number. You MUST read the input character by character. You are to report the errors and the valid input.
NOTE: you are to process an entire line of input
You must define a class and use an object to handle the error handling.
The class should include a string with the error message and an associated integer code. Recall the sample code that used a user defined class to handle exceptions

For example:
InputOutput
x ID
1238 integer
0.4089 decimal
2134.9 decimal
x-db Invalid ID. - found
xy78 Invalid ID. 7 found
456. Invalid decimal. Missing digit
. Invalid decimal. Missing digit
.3 Invalid decimal. Missing digit
x y 8 9.4 ID ID integer decimal

Start with this code

  1. Add a string error message data member and a setter and getter
  2. Create a function to handle alphabetic characters that is called after item[0] is determined to be a letter (instead of the cout)
  3. Create a function to handle numbers that is called when item[0] is a digit
  4. Add a else if for a '.' and sets the character, number, and a message of "Invalid Decimal. Missing Digit"
  5. When individual items are working, modify main so the the try and catch are INSIDE the do { }while():
    do { 
      try {
       next = ...
       cout ...
       analyze ...
      }
      catch ( ...
      {
        cout ...
      }
    } while ( ...
    

To hand in this assignment:
Place the code and sample output in the Exceptions Dropbox on D2L