Strings, File I/O

You are free to use a single or multiple files for this project. If you are putting all functions in a single file, make sure that more abstract functions are defined first.
  1. Check. Study code folding in MSVS described here. As you work on the below project, demonstrate to the lab instructor code folding and unfolding. Create a project titled Lab7_Check. Write a program that asks the user the check information and prints the check. The dialog should be as follows:
    date: 2/23/2010
    name: William Schmidt
    amount, dollars: 23
    cents: 30
    payee: Office Max
    
    
    your check:
    
    William Schmidt                       10/13/2013
    pay to:  Office Max                   $23.30
    twenty three and 30/100               dollars
    
    
    You may assume that a person always has the first name and last name (no middle names or initials). The payee name is also always two words. The dollar and cent amount are integers and the amount is always less than 100 dollars. Note that the dollar amount could be zero, in which case, when you spell the dollar amount, it should print "zero". The date is always a single (non-white space separated string). Your date, dollar amount in numbers and the word "dollars" have to vertically align.

    Hints: You may reuse your code from the number spell assignment to spell out the number of dollars. Putting it in a separate function will make the code more modular. Output appropriate number of spaces in the shorter lines to pad them to the right size so that the information is aligned. Some of the functions from this example program may be useful. To calculate the number of spaces, use the string size() function to compute the size of the strings on the left.

  2. File. Create a project titled Lab7_File. Repeat the assignment assuming that the input comes from a file such as this one You can save the file in your computer (cut-and-paste is acceptable) in file database.txt. In Visual Studio, you can just add this file to your project just as you do with source and header files. The output of your program should go to a different file named check.txt. Again, you can add this file to the project and observe its contents.

    You may reuse the code from the first part of the lab assignment. You may assume that in the input file, the fields are always named the same and the order of the fields is the same. However, the data fields of the file may change. That is, you may not program your assignment such that it only works with the provided example file.

    Hints: Note that you can recognize words that denote the names of the fields in the database files such as last name: by comparing them to literal string constants or (simpler) you can just exploit the fixed order of the fields, read these names and immediately discard them. That is, we already know that the name would the the forth and fifth string input and the cent amount is the tenth. So you only need to process the fifth string, the tenth string and so on.

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.