Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The given program reads a list of single-word first names and ages (ending with -1) , and outputs that list with the age incremented. By single word - you would not use getline. The program fails and throws an exception if the second input on a line is a string rather than an int. At FIXME in the code, add a try/catch statement to catch ios_base::failure, and output 0 for the age.

...

Code Block
Lee 18
Lua 21
Mary Beth 19
Stu 33
-1

The output would be :(after all the input has been given above)

Code Block
Lee 19
Lua 22
Mary 0
Stu 34

...