Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The file I:\\stu_data\\Wei\\Customers.txt Contains the following data items on e

ID: 3531095 • Letter: T

Question

The file I:stu_dataWeiCustomers.txt Contains the following data items on each record: CustomerID CompanyName ContactName ContactTitle Address City Region PostalCode Country Phone Fax (The first record has the title of each column. Data fields on each record are tab (' ') separated.) Use object oriented design to create a solution which will allow the user to display a single record by providing just the CustomerID. 1. The program should allow multiple queries and for each retrieved record it should format (with field title) and display the record. Such as: CustomerID: ALFKI CompanyName: Alfreds Futterkiste ContactName:Maria Anders ContactTitle: Sales Representative Address: Obere Str. 57 City: Berlin Region: PostalCode: 12209 Country: Germany Phone: 030-0074321 Fax: 030-0076545 *********70% 2. The solution should also allow new customer records to be added to the database and old records deleted from the database *********30%

Explanation / Answer

#include <cstdio>

#include <cstdlib>

#include <iostream>

#include <fstream>

#include <string>


class customer{

String filename = "I:stu_dataWeiCustomers.txt";

int search(int id)

{

string line = "";

string A;

int ID;

ifstream infile;

infile.open(filename);

getline(infile,line);

while(!infile.eof())

{

getline(infile,line);

A = strtok(line," ");

ID = atoi(A);

if(id == ID)

{

while (A != NULL)

{

printf ("%s ",A);

A = strtok (NULL, " ");

}

printf(" ");

return 1;

}

}

printf("Record Not Found ");

return 0;

}

int delete(int id)

{

String line = "";

String out="";

String A;

int ID;

ifstream infile;

infile.open(filename);

getline(infile,line);

out = out + " " + line;

while(!infile.eof())

{

getline(infile,line);

A = strtok(line," ");

ID = atoi(A);

if(id != ID)

{

out=out+" "+line;

}

}

ofstream myfile (filename);

myfile << out;

myfile.close();

return 1;

}

int insert(int ID, String CompanyName, String ContactName, String ContactTitle, String Address, String City, String Region, String PostalCode, String Country, String Phone, String Fax)

{

String out = ID + " "+CompanyName+ " "+ ContactName+ " "+ ContactTitle + " "+Address + " "+City + " "+Region + " "+PostalCode + " "+Country + " "+Phone + " "+Fax+" ";

std::ofstream outfile;

outfile.open("test.txt", std::ios_base::app);

outfile << out;

outfile.close();

return 1;

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote