You will be creating a christmas card address file. To create this file, you will work with a named input file, an output file that is opened in both out and app modes, a few ctype functions, and the string class. The program should be written so that the main function does little else but call other functions such as: PrintGreetingScreen - print a greeting on screen that explains purpose of the program. Let the user press enter key to continue. OpenInputFile OpenOutputFile ReadInRecords DisplayRecordsOnScreen WriteToOutputFile OpenOutputFileInAppend AddNewRecords PrintCosingScreen - print closing message on screen and let user press enter to exit the program Other requirements for the program are: 1. The input file for this lab is addressList.txt. Get a copy from my website. 2. The addressList.txt input file has been written using a dollar sign($) as a field delimiter. Each line of data in the file contains information for one record (last name, first name, street address, city, state, zip code). All fields except for the state and zip code may contain spaces. The state fiels will contain only the two letter state abbreviation. The zip code will be a 5 digit number. The field sizes for the first 4 fields needs to be resized so that each fiels is the size listed as follows: Last name - new field size 20 First name - new field size 20 Street address - new field size 25 City - new field size 20 3. Using the addressList.txt input file, write a program that will perform the following tasks: a. read the data one field at a time from addresslist.txt input file using string class data type. the input file stream should be declared as ifstream. print copies of the incoming records on the screen in format of your choice as you process them. b. resize each field to its appropriate size as show above. if field is less than required size pad the end of the field with spaces. c. combine all fields from one record into a single string in this order: last name, first name, street address, city, state, zip code. do not put $ back into the record. Store all the new records into another string array called newStrings. Each element in this array will be 92 bytes long. this is the array you will pass in the main function to WriteToOutputFile. d. Write the newly combined string records to an output file called lab3output.txt. this file should be declared as an ofstream type and opened initally with a file access flag ios::out. WriteToOutputFile is a function that should be called to the main function. 4. After you have converted all the records from the input file and written them to the output file, close the output file. 5. Reopen the output file using a file access flag ios::app 6. Allow the user to enter information to add to the christmas card list using the following data validation: a. the last name, first name, and city fields must contain no less than 1 and no more than 20 characters. if this condition is not met, ask the user to reenter the data. b. the street address field must contain no less than 1 and no more than 25 characters. if condition is not met, ask user to reenter data. c. the state abbreviation field must contain exactly 2 characters and must be one of the 50 correct state abbreviations. if condition is not met, reenter. d. the zip code field must contain exactly 5 characters and they must be digits. if condition is not met, reenter. 7. After the user has enter all the data for one record, perform the following tasks: a. resize the last name, first name, street address, and city fields so they match the values given in the table above. if the field is less than required size pas end of field with spaces. b. combine all fields of one record into a single string as in step 3c above c. write the new record to the output file so that it is appended to the end of the file d. the program should allow the user to enter the data for new records until the user wishes to terminate the process. 8. Allow a maximum of 50 records in the final file. That is, after reading in all current records and then allowing user to add additional records, you will not allow more than 50 records total in the final file. this when you declare the array, you may use a MAX-SIZE of 50. |
|
|
Santa's Little Helper The business is going bad this year for Santa. So he decided to sell his famous list to the International Committee of Publicity and Commerce (ICPC), that will use it to improve the quality of life of the people. The ICPC requires an special format for these important documents, so Santa has contracted you to make a program that would fix all his registers Input The input contains a lot of registers. Each register has the fields: last name, first name, street address, city, state and zip code, delimited by a dollar sign( '$' )Output Output all the registers using a fixed field width (filled with spaces ' ' ) and without delimiterThe fields widths are Last name 20 First name 20 Street address 25 City 20 State 2 Zip code 5 Example input
Example output
|
|
|