C++ Program This program will store structure data in a file called Customers.dat. For this assignment, create a menu with the following tasks: 1. Add DataX . Exit Program This menu needs to display "Invalid choice" if '1' or 'X' is not the given choice. The menu should redisplay options until item 'X' is selected. Prior to this menu loop, the program needs to create the Customers.dat file if it does not existThe file "Customers.dat" must be opened in Binary mode. The file is opened for processing prior to the menu. This program may be written to automatically reset an existing Customers.dat file if it already exists. For option '1', prompt to enter the highlighted data items in the structure below. This is every item except customerNumber , isDeleted and newLine; 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; }; Always set the item isDeleted to 'N' and newline to '\n'. The item newLine is a convenient item that is there to assist in viewing the contents of the file using "type filename" in the cmd window. The item customerNumber should start at 0 and increase by 1 for every record written. This data item is not viewable in the file via notepad because it is stored in a binary format. Notepad will show the binary chars and will not line up the data as expected. You may see some odd characters after the expected data for the character arrays. That is normal for C/C++. Once the data in the structure is loaded, append the structure to the file "Customers.dat" and return to the menu. For option 'X': Close the data file display "Done!" Let the program terminate.
C++
This program will store structure data in a file called Customers.dat.
For this assignment, create a menu with the following tasks:
1. Add DataX
. Exit Program
This menu needs to display "Invalid choice" if '1' or 'X' is not the given choice. The menu should redisplay options until item 'X' is selected.
Prior to this menu loop, the program needs to create the Customers.dat file if it does not existThe file "Customers.dat" must be opened in Binary mode.
The file is opened for processing prior to the menu.
This program may be written to automatically reset an existing Customers.dat file if it already exists.
For option '1', prompt to enter the highlighted data items in the structure below. This is every item except customerNumber , isDeleted and newLine;
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;
};
Always set the item isDeleted to 'N' and newline to '\n'. The item newLine is a convenient item that is there to assist in viewing the contents of the file using "type filename" in the cmd window.
The item customerNumber should start at 0 and increase by 1 for every record written. This data item is not viewable in the file via notepad because it is stored in a binary format.
Notepad will show the binary chars and will not line up the data as expected. You may see some odd characters after the expected data for the character arrays. That is normal for C/C++.
Once the data in the structure is loaded, append the structure to the file "Customers.dat" and return to the menu.
For option 'X':
Close the data file
display "Done!"
Let the program terminate.

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









