Question: #include #include #include #include #include #include using namespace std; const int NAME_SIZE = 51; const int ADDR_SIZE = 51; const int CITY_SIZE = 20; const

#include #include #include #include #include #include using namespace std;

const int NAME_SIZE = 51; const int ADDR_SIZE = 51; const int CITY_SIZE = 20; const int STATE_SIZE = 15; const int ZIP_SIZE = 6; const int PHONE_SIZE = 14; const int PAYMENT_DATE_SIZE = 11; struct Customer { char name[NAME_SIZE]; char address[ADDR_SIZE]; char city[CITY_SIZE]; char state[STATE_SIZE]; char zip[ZIP_SIZE]; char phone[PHONE_SIZE]; double acct_balance; char payment_date[PAYMENT_DATE_SIZE]; }; void displayMenu(); int getMenuChoice(); int enterRecords(Customer); int searchName(Customer); int searchAndDisplay(Customer); int searchAndDelete(Customer); int searchAndChange(Customer); void showRecord(Customer); int displayContents(Customer);

int main() { int choice; char again = 'N'; Customer person; do { displayMenu(); choice = getMenuChoice(); switch(choice) { case 1: enterRecords(person); break; case 2: searchAndDisplay(person); break; case 3: searchAndDelete(person); break; case 4: searchAndChange(person); break; case 5: displayContents(person); break; case 6: cout > again; while (again != 'Y' && again != 'y' && again != 'N' && again != 'n') { cout > again; } cin.ignore(); } while (toupper(again) == 'Y'); cout

void displayMenu() { cout

int getMenuChoice() { int choice; cout > choice; cin.ignore(); while (choice 6) { cout > choice; } return choice; }

int enterRecords(Customer person) { char again; fstream records("records.dat", ios::out | ios::app | ios::binary); if (!records) { cout > person.acct_balance; cin.ignore(); cout (&person), sizeof(person)); cout > again; while (again != 'Y' && again != 'y' && again != 'N' && again != 'n') { cout > again; } cin.ignore(); } while (toupper(again) == 'Y'); records.close(); }

int searchName(Customer person) { char name[NAME_SIZE]; bool found = false; int pos = 0; fstream records; records.open("records.dat", ios::in | ios::binary); if (!records) { cout (&person), sizeof(person)); while (!records.eof()) { if (strcmp(person.name, name) == 0) { found = true; break; } // If name wasn't found in the first record, read the next record from the file. records.read(reinterpret_cast(&person), sizeof(person)); pos++;

} records.close(); if (found == true) . { cout

int searchAndDisplay(Customer person) { long recNum; cout (&person), sizeof(person)); showRecord(person); records.close(); }

int searchAndChange(Customer person) { long recNum; cout (&person), sizeof(person)); showRecord(person); cout > person.acct_balance; cin.ignore(); cout (&person), sizeof(person)); records.close(); }

int searchAndDelete(Customer person) { long recNum; int count = 0; cout (&person), sizeof(person)); while(!records.eof()) { if(deleteLocation != ((count) * sizeof(person))) { records.seekg((count) * sizeof(person), ios::beg); records.read(reinterpret_cast(&person), sizeof(person)); tempFile.write(reinterpret_cast(&person), sizeof(person)); count++; } } tempFile.close(); records.close(); remove("records.dat"); rename("tempFile.dat", "records.dat"); }

void showRecord(Customer person) { cout

int displayContents(Customer person) { fstream records; records.open("records.dat", ios::in | ios::binary); if (!records) { cout (&person), sizeof(person)); while (!records.eof()) { showRecord(person); records.read(reinterpret_cast(&person), sizeof(person)); } cout

#include #include #include #include #include #include using namespace std; const int NAME_SIZE

Above is the code that was posted by an expert in response to my question. When I run the code above, my program isn't functioning correctly. There are no errors in the error box, and I created the records and temp files (I changed them to .txt instead of .dat). But, when I run the code and enter a menu choice, the program aborts. I don't know what's wrong with it. (I had to change the format in order to post the question.)

16. Customer Accounts his program should be designed and written by a team of students. Here are some suggestions One student should design function main, which will call other program functions The remainder of the functions will be designed by other members of the team The requirements of the program should be analyzed so each student is given about the same workload Write a program that uses a structure to store the following data about a customer account: Name Address City, State, and ZIP Telephone Number Account Balance Date of Last Payment The structure should be used to store customer account records in a file. The program should have a menu that lets the user perform the following operations: .Enter new records into the file. Search for a particular customer's record and display it . Search for a particular customer's record and delete it. Search for a particular customer's record and change it. e Display the contents of the entire file. Input Validation: When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balances should be entered

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!