Question

In C++, You are given a file of customer data with records in the following format...

In C++,

You are given a file of customer data with records in the following format : account number, last name, first name, middle name. Write a program to convert the input data and display it to the monitor in the following format :

Accout Name     Logon ID Initial Pswd

21-88282712-B Keith S. Adams ADAM21 Adam88282

08-36847734-A John R. Sturm STUR08 Stur36847

   etc.

Notes :

    1) The account number on the input is 10 digits

    2)  The names on the input file are 2 strings. The first incoming name string variable has last name, comma and first name in it. The second one contains the

middle name.

    3) The outputted account must contain hyphens as shown above. The first 2 digits of the account determine the letter at the end of the outputted account : For

instance, if the first 2 digits are between 01 and 10 inclusive, the ending letter is A, if the first 2 digits are between 11 and 20 inclusive, the ending letter is B, and

so on..

    4) The ouputted name is : first name, middle initial, last name.    Use the string function find to find the index of , ; the function length to find the length of the

string; and the function substr to extract the first name, last name and middle initial. See table 7-1 in the textbook.

   5) Logon ID is formed by taking first 4 characters of last name and making them uppercase, then appending the first 2 digits of the account number.

The toupper(x) function can be used to obtain the uppercases of the letter.

6) Initial Pswd consists of up to the first 4 characters of last name and the third to seventh digits of account number

    7)  Include the column headings in the output and be sure the columns are centered under the headings.

8) The attached program can be used as a basis for your program.

9) Test with the attached data file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream> #include <fstream> #include <string> #include <ctype.h> using namespace std; int main () //declare variabcoutくくfirstname [1]くくmiddletname [1] << . <<lastname [i] ; cout<<\tくくlastname [i] ; cout<<\tくくlastname [i] ; coutくく\nDefault Term sh-4.3$ main Account 2188282712B Keith 0836847734A JohnR.Sturm Initial password Name Logon ID S.Adams Adams Adamcode:

#include <iostream>
#include <fstream>
#include <string>
#include <ctype.h>
using namespace std;
int main ()
//declare variables
{
string accno[10];
string firstname[10];
string middletname[10];
string lastname[10];
short i=0;
int k=1;
ifstream myfile ("employee.txt");
cout<<"Account\t"<<"\t\t Name" <<"\t Logon ID"<<"\t Initial password\n";
if (myfile.is_open())
{
while (! myfile.eof() )
{
  
myfile>> accno[i] >>firstname[i]>>middletname[i]>>lastname[i];
  
cout << accno[i]<<"\t";
cout<<firstname[i]<<middletname[i]<<"."<<lastname[i];
cout<<"\t"<<lastname[i];
cout<<"\t"<<lastname[i];
cout<<"\n";
i++;
}
  

myfile.close();
}
else cout << "error";
  
return 0;
}

Add a comment
Know the answer?
Add Answer to:
In C++, You are given a file of customer data with records in the following format...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C program Consider a file that contains employee records, called "empstat.txt." The data for each...

    In C program Consider a file that contains employee records, called "empstat.txt." The data for each employee consist of the employee’s last name (up to 20 characters), employee id number (up to 11 characters), gross pay for the week (double), taxes deducted (double) for the week, and net pay (double) for the week. Create a struct to hold the employee information. Write a void function called writeEmpFile that prompts the user to enter last name, id number, gross pay and...

  • Write a C program to compute average grades for a course. The course records are in...

    Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...

  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data...

    need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and   last name). b) Define...

  • C++ A professor plans to store the following data for each of his students: Last Name,...

    C++ A professor plans to store the following data for each of his students: Last Name, First Name, Class Average (as a double), Letter Grade (“A”, “A-“, “B+”, “B”, etc.) Write two programs for writing and reading such a file, with the user choosing the file name. Store the (int) number of students as the first data value in the file, followed by \n. Then use the following delimiter scheme: Last Name(comma)First Name(comma)Average(space)Letter Grade(newline) For the file writer program, input...

  • Your task for this project is to write a parser for a customer form. You need to develop a Java a...

       Your task for this project is to write a parser for a customer form. You need to develop a Java application using Parboiled library. Your program should include a grammar for the parser and display the parse tree with no errors. Remember that your fifth and sixth assignments are very similar to this project and you can benefit from them. The customer form should include the following structure: First name, middle name (optional), last name Street address, city, state (or...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of...

    ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file. Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25...

  • I need a C++ program like this please! and please follow all instructions! Thanks so much!...

    I need a C++ program like this please! and please follow all instructions! Thanks so much! A menu-driven program with 3 choices: Names Rearranger, Number Validator, or Exit Menu Option 1: Name Rearranger: 1. Input ONE STRING from the user containing first name, middle name, and last name. ie, "John Allen Smith". USE THE GETLINE function. (Not cin) 2. Loop through the string and validate for a-z or A-Z or . If the name has any other characters, then ask...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT