PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code. Along with the proper indenting it makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/ Hint: You can edit your post, highlight your code and press the <> formatting button. You can use the preview button at the bottom to see how it looks. I found the second link to be the most help. |
Write a program that will create user ids for email addresses of a company. Names of employees will be contained in a file. 2. Your task is to read the file character by character. Employee names are separated by semicolons. The process of creating a user id is as follows: 3. The first 8 characters, excluding spaces and non-alphabetical characters becomes the user id. Your program will therefore ignore all spaces and non-alphabetical characters from the input file. If the employee name excluding spaces and non-alphabetical characters consists of less than 8 characters, the userid will also contain less than 8 characters. (e.g. JG Smit will give a userid of jgsmit and GM Bezuidenhout will give a userid of gmbezuid. You will however not work with the full surname. 4. Your program will read character by character, and form the user id as you go along, adding each new character of the id to the output file. Call the output file userid.dat. As soon as you read a semicolon, the previous userid is complete and you can then write the semicolon to the output file to separate the userids. 1. You therefore have to plan the logic properly, so that you don’t have to go back to the output file to delete characters that should not be there. Create an input file called employee.dat employee.dat with the following data: SS van der Merwe;PJ Ferreira;HW du Plessis;DF Kodisang; |
You will however not work with the full surname. |
SS van der Merwe PJ Ferreira HW du Plessis DF Kodisang Press Enter to continue: |
open an input stream open an output stream set currentLength to 0 while you can read a char from input: if the char is a semicolon: write a semicolon to output set currentLength to 0; else if it's a letter and currentLength is less than 8: write the lowercase letter to output increment current length |
SSvander@someshere.com PJFerrei@someshere.com HWduPles@someshere.com DFKodisa@someshere.com |