Objectives
- Create an input loop to enter data
- Stop input when the user chooses to end it
- Validate user input using functions
- Convert strings to uppercase
- Write data to a sequential access text file
This assignment involves the creation of a sequential access, text, variable-length record data file. You will create the user interface and store the data the user enters. Each record in the file has the following fields:
The following code requires the C++ libraries: cctype, string
Enter dept ID: it Employee ID: d4772 Enter month: 1 Enter day: 2 Enter year: 2011 Enter hours: 8.25 Enter another record (Y/N)? y Enter dept ID: it Employee ID: f9642 Enter month: 1 Enter day: 4 Enter year: 2011 Enter hours: 8.25 Enter another record (Y/N)? n
The file so far would look like this:
IT,D4772,1,2,2011,8.25 IT,F9642,1,4,2011,8.25
Enter dept ID: IT Employee ID: V1001 Enter month: -9 Error: Value below minimum of 1 Enter month: 1 Enter day: 34 Error: Value above maximum of 31 Enter day: 3 Enter year: 08 Error: Value below minimum of 2000 Enter year: 2011 Enter hours: 480 Error: Value above maximum of 24 Enter hours: 5.25 Enter another record (Y/N)? Y Enter dept ID: mgt Employee ID: a0010 Enter month: 1 Enter day: 2 Enter year: 2011 Enter hours: 6.5 Enter another record (Y/N)? p Error: Invalid choice Enter another record (Y/N)? n
The file would now look like this:
IT,D4772,1,2,2011,8.25 IT,F9642,1,4,2011,8.25 IT,V1001,1,3,2011,5.25 MGT,A0010,1,2,2011,6.5