SuperTutor

(15)

$15/per page/Negotiable

About SuperTutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Business & Finance See all
Accounting,Business & Finance,Economics,Engineering,HR Management,Math Hide all
Teaching Since: Apr 2017
Last Sign in: 234 Weeks Ago, 1 Day Ago
Questions Answered: 12843
Tutorials Posted: 12834

Education

  • MBA, Ph.D in Management
    Harvard university
    Feb-1997 - Aug-2003

Experience

  • Professor
    Strayer University
    Jan-2007 - Present

Category > Programming Posted 10 Jul 2017 My Price 20.00

Create a C++ console application

Create a C++ console application that will store and retrieve names and addresses in a text file.
The program should do the following.
1. It should accept a series of names and addresses from the console.
2. The user's input should be written to a text file in the CSV format described in the lesson, but do not
include the field names in the first row of the file. Use a delimiter to separate the records.
3. Read the records from the text file, and display them in a user-friendly format.
4. Provide a menu to allow the user to append records to the file, display the records, or exit the
application.
Build upon the code below to complete the assignment.
//Specification: Append and display records in a address database
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void menu(void);
void writeData(void);
void readData(void);
const char FileName = "TestAddress.txt";
int main () {
menu();
return 0;
} //end main
void menu(void) {
//allow user to choose to append records, display records or exit the program
}//end menu
void writeData(void){
//Write the Address Info to a file
//loop while user still has data to write to file
//eg outStream<<name<<”#”; //where # is the delimiter }//end write data
void readData(void){
//read data from a file
//use the split function to break a
//deliminated line of text into fields
ifstream inMyStream (FileName);
if (inMyStream.is_open()) {
//set character to use as a line between record displays
string recBreaks = "";
recBreaks.assign(20,'-');
int fieldCount = 0; //keep track of the number of fields read
int recordCount = 1; //keep track of the number of records
read
//read the first field
fieldCount = 1;
string fieldBuffer;
getline (inMyStream, fieldBuffer, '#');
while (!inMyStream.eof() ){
//display the field
switch (fieldCount) {
case 1:
cout << recBreaks << endl;
cout << "record # " << recordCount
<< endl;
cout << "Name...." << fieldBuffer <<
endl; break;
case 2:
cout << "Street.." << fieldBuffer <<
endl; break;
case 3:
cout << "City...." << fieldBuffer <<
endl; break;
case 4:
cout << "State..." << fieldBuffer <<
endl; break;
case 5:
cout << "Zip....." << fieldBuffer <<
endl;
fieldCount = 0;
recordCount++;
}
//read the next field break; getline (inMyStream, fieldBuffer, '#');
fieldCount++;
}
cout << recBreaks << endl;
inMyStream.close(); }//end read data Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
The pseudocode for the writeData function is shown below. Start
open the text file to append
start do while loop
Allow user to enter name
store name (using getline method)
Allow user to enter city
store city (using getline method)
.
.
write name, city, etc. to the file
end loop
close the file
End The program input should appear similar to this.
Append Records Name..........John Smith
Street.........902 Union Ave
City............Any Town
State...........TX
Zip Code......78552
"Enter another Record? (Y/N) "
The file structure should look like this.
John Smith, 902 Union Ave, Any Town, TX,
79552
Eric Jones, 345 State Way, Fresno, CA,
93432
...
The file output should appear similar to the following.
Show Records
___________________________________
_______
Record #1
Name...........John Smith
Street..........902 Union Ave
City.............Any Town
State...........TX
Zip Code......78552
___________________________________
_______
Record #2
Name...........Eric Jones
Street..........345 State Way
City.............Fresno
State...........CA
Zip Code.......93432
___________________________________
_______
(A)ppend Records, (S)how Records, (E)xit

 

Attachments:

Answers

(15)
Status NEW Posted 10 Jul 2017 06:07 AM My Price 20.00

-----------

Attachments

file 1499670049-Solutions file.docx preview (51 words )
S-----------olu-----------tio-----------ns -----------fil-----------e -----------Hel-----------lo -----------Sir-----------/Ma-----------dam----------- T-----------han-----------k y-----------ou -----------for----------- yo-----------ur -----------int-----------ere-----------st -----------and----------- bu-----------yin-----------g m-----------y p-----------ost-----------ed -----------sol-----------uti-----------on.----------- Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m o-----------nli-----------ne -----------or -----------inb-----------ox -----------me -----------a m-----------ess-----------age----------- I -----------wil-----------l b-----------e q-----------uic-----------kly----------- on-----------lin-----------e a-----------nd -----------giv-----------e y-----------ou -----------exa-----------ct -----------fil-----------e a-----------nd -----------the----------- sa-----------me -----------fil-----------e i-----------s a-----------lso----------- se-----------nt -----------to -----------you-----------r e-----------mai-----------l t-----------hat----------- is----------- re-----------gis-----------ter-----------ed -----------on-----------th-----------is -----------web-----------sit-----------e -----------Tha-----------nk -----------you----------- -----------
Not Rated(0)