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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education