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
|
struct CustomerAccountRecords
{
string fullName, lastName;
string streetAddress, city, state;
int zipCode = 0,lastPaymentDate = 0;
long long int phoneNumber = 0;
double accountBalance = 0;
};
int main()
{
CustomerAccountRecords *recordPtr = nullptr;
recordPtr = new CustomerAccountRecords[100];
int choice = 0, numRecords = 0;
fstream RecordFile;
do {
cout << endl;
choice = Menu();
switch (choice) {
case 1:
NewCustomerRecord(recordPtr, numRecords);
numRecords++;
SortRecords(recordPtr, numRecords);
break;
case 2:
DisplayCustomerRecord(recordPtr, numRecords);
break;
case 3:
DeleteCustomerRecord(recordPtr, numRecords);
numRecords--;
break;
case 4:
EditCustomerRecord(recordPtr, numRecords);
SortRecords(recordPtr, numRecords);
break;
case 5:
SortRecords(recordPtr, numRecords);
DisplayAllRecords(recordPtr, numRecords);
break;
case 6:
SortRecords(recordPtr, numRecords);
SaveCustomerRecords();
break;
}
} while (choice < 6 || choice > 0);
delete[] recordPtr;
RecordFile.close();
return 0;
}
void SortRecords(CustomerAccountRecords* ptr, int SIZE)
{
int minIndex, size = 100;
string firstName;
for (int start = 0; start < size - 1; start++) {
minIndex = start;
for (int i = start + 1; i < size; i++) {
if (ptr[i].lastName < ptr[minIndex].lastName) {
minIndex = i;
}
swap(ptr[minIndex].lastName, ptr[start].lastName);
swap(ptr[minIndex].accountBalance, ptr[start].accountBalance);
swap(ptr[minIndex].lastName, ptr[start].lastName);
swap(ptr[minIndex].city, ptr[start].city);
swap(ptr[minIndex].fullName, ptr[start].fullName);
swap(ptr[minIndex].lastPaymentDate, ptr[start].lastPaymentDate);
swap(ptr[minIndex].phoneNumber, ptr[start].phoneNumber);
swap(ptr[minIndex].state, ptr[start].state);
swap(ptr[minIndex].streetAddress, ptr[start].streetAddress);
swap(ptr[minIndex].zipCode, ptr[start].zipCode);
}
}
}
|