Question: Create a menu for the following tasks: 1. Add Customer Data 2. Show Existing Customer Data 3. Delete Customer Data 4. UnDelete Customer Data X.

Create a menu for the following tasks:

1. Add Customer Data
2. Show Existing Customer Data
3. Delete Customer Data 4. UnDelete Customer Data
 

X. Exit

Menu Item 1 should do the tasks originally done in Assignment 2.

Menu Item 2 should be a coded in a method showExistingCustomerData. It should read the "Customer.dat" file and display CustomerNumber, CustomerName and isDeleted.

Menu Item 3 should prompt for a Customer Number to delete. It should then read the Customer Data file and if a matching customer is found, it should changed the item isDeleted to Y and 'update' the file. If no customer number is found, it should display "Customer Number #### not found to delete.". ( ##### is the entered customer number). If the customer is already deleted, it should display "Customer is already deleted".

A note regarding 'updates'. You can rewrite the entire structure or use the file.seekp methods to do the updates.

Menu Item 4 should prompt for a Customer Number to un-delete. It should then read the Customer Data file and if a matching customer is found, it should changed the item isDeleted to N and 'update' the file. If no customer number is found, it should display "Customer Number #### not found to delete.". ( ##### is the entered customer number). If the customer is already not deleted, it should display "Customer is not already deleted"

Tips:This task may require you to change how the file is opened or optionally use additional file open and closes. Always confirm the file does not get deleted after a program restart.

(Assignment 2) #include #include using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; struct Customers { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode; char isDeleted; char newLine; }; int main() { struct Customers c; long cus_num = 0; char choice; fstream f("customers.txt",ios::out|ios::binary|ios::app); do { cus_num++; c.customerNumber = cus_num; f << c.customerNumber << " "; cout << " Please enter your name: "; cin >> c.name; f << c.name << " "; fflush(stdin); cout << " Please enter street address 1: "; cin >> c.streetAddress_1; f << c.streetAddress_1 << " "; fflush(stdin); cout << " Please enter street address 2: "; cin >> c.streetAddress_2; f << c.streetAddress_2 << " "; fflush(stdin); cout << " Please enter city: "; cin >> c.city; f << c.city << " "; fflush(stdin); cout << " Please enter state: "; cin >> c.state; f << c.state << " "; fflush(stdin); cout << " Please enter zip code: "; cin >> c.zipCode; f << c.zipCode << " "; c.isDeleted = 'N'; f << c.isDeleted << " "; c.newLine=' '; f << c.newLine; cout << " Do you want to continue with more records [y/n] : "; cin >> choice; }while(choice == 'y' || choice == 'Y'); cout << " The data is successfully stored in the file customers.txt" << endl; f.close(); }

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!