1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
struct CustomerAccountRecords
{
string fullName;
string streetAddress, city, state;
int zipCode, phoneNumber, lastPaymentDate;
double accountBalance;
};
int main()
{
CustomerAccountRecords *recordPtr = nullptr;
recordPtr = new CustomerAccountRecords[100];
int choice = 0, numRecords = 0;
fstream RecordFile;
RecordFile.open("CustomerRecords.dat", ios::in | ios::binary);
if (RecordFile) {
while (!RecordFile.eof()) {
RecordFile.read(reinterpret_cast<char*>(recordPtr), sizeof(*recordPtr));
getline(cin, recordPtr[numRecords].fullName);
40 cin.getline(recordPtr[numRecords].streetAddress, '\n');
41 cin.getline(recordPtr[numRecords].state, '\n');
cin >> recordPtr[numRecords].zipCode;
cin >> recordPtr[numRecords].phoneNumber;
cin >> recordPtr[numRecords].accountBalance;
cin >> recordPtr[numRecords].lastPaymentDate;
numRecords++;
}
SortRecords(numRecords);
RecordFile.open("CustomerRecords.dat", ios::out | ios::app | ios::binary);
}
else {
RecordFile.open("CustomerRecords.dat", ios::out | ios::binary);
}
do {
choice = Menu();
switch (choice) {
case 1: NewCustomerRecord(recordPtr, numRecords);
break;
case 2: DisplayCustomerRecord(recordPtr, numRecords);
break;
case 3: DeleteCustomerRecord();
break;
case 4: EditCustomerRecord();
break;
case 5: DisplayAllRecords();
break;
case 6: SaveCustomerRecords();
break;
}
} while (choice > 6 || choice < 1);
delete[] recordPtr;
RecordFile.close();
return 0;
}
void NewCustomerRecord(CustomerAccountRecords *ptr, int recordNum)
{
string firstName, lastName, space = " ";
cout << "Enter New Customer Account Information Below: " << endl;
cout << "Full Name: ";
101 cin.getline(ptr[recordNum]->fullName, '\n');
cout << "Street Address: ";
103 cin.getline(ptr[recordNum]->streetAddress, '\n');
cout << "City: ";
getline(cin, ptr[recordNum]->city);
cout << "State: ";
cin.getline(ptr[recordNum]->state, '\n');
do {
cout << "ZIP Code: ";
cin >> ptr[recordNum]->zipCode;
} while (ptr[recordNum]->zipCode > 99999 || ptr->zipCode < 10000);
do {
cout << "Telephone Number: ";
cin >> ptr[recordNum]->phoneNumber;
} while (ptr[recordNum]->phoneNumber > 9999999999 || ptr[recordNum]->phoneNumber < 1000000000);
do {
cout << "Account Balance: ";
cin >> ptr[recordNum]->accountBalance;
} while (ptr[recordNum]->accountBalance < 0);
do {
cout << "Date of Last Payment (MMDDYYYY): ";
cin >> ptr[recordNum]->lastPaymentDate;
} while (ptr[recordNum]->lastPaymentDate > 99999999 || ptr[recordNum]->lastPaymentDate < 10000000);
SortRecords(recordNum);
recordNum++;
}
|