2. Update Data 3. Display all data X. Exit Program 3. Create a method called "getLargestCustomerNumber" and call it after the "Customers.dat" file has been opened. Read all the existing customerNumbers and dete adding new customer data. 4. The program should be able to start multiple times and add data with increasing customerNumbers. There should be no duplicated customer numbers. 5. Menu Option 2 should do the following tasks a. Prompt for a customer number to change. b. Enter the address information ( Street 1 & 2, City , State and Zipcode) c. Find the record for the customer number and replace the address information. 6. Menu Option 3 should do the following tasks a. Reset the file pointer to the beginning of the file.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Copy Assignment 1 to Assignment 2. Relabel this assignment to be Assignment 2. If there were comments made regarding the grading of Assignment 1, apply those changes to assignment 2.
1. Modify this program to open the file "Customers.dat" so that all data can be read, and data written or appended to this file.
2. Add an option 2 and 3 to the menu so that the menu appears as below:Menu options '2' and '3' should now be considered a valid choice.
1. 1. Add Data
2. Update Data
3. Display all data
X. Exit Program
3. Create a method called "getLargestCustomerNumber" and call it after the "Customers.dat" file has been opened. Read all the existing customerNumbers and determine the largest customerNumber. Use this number as the base when
adding new customer data.
4. The program should be able to start multiple times and add data with increasing customerNumbers. There should be no duplicated customer numbers.
5. Menu Option 2 should do the following tasks
a. Prompt for a customer number to change.
b. Enter the address information ( Street 1 & 2, City, State and Zipcode)
c. Find the record for the customer number and replace the address information.
6. Menu Option 3 should do the following tasks
a. Reset the file pointer to the beginning of the file.
b. For each record in the file, display the customer number, customer name and all address information. The items isDeleted and newLine are not to be displayed.
Transcribed Image Text:Copy Assignment 1 to Assignment 2. Relabel this assignment to be Assignment 2. If there were comments made regarding the grading of Assignment 1, apply those changes to assignment 2. 1. Modify this program to open the file "Customers.dat" so that all data can be read, and data written or appended to this file. 2. Add an option 2 and 3 to the menu so that the menu appears as below:Menu options '2' and '3' should now be considered a valid choice. 1. 1. Add Data 2. Update Data 3. Display all data X. Exit Program 3. Create a method called "getLargestCustomerNumber" and call it after the "Customers.dat" file has been opened. Read all the existing customerNumbers and determine the largest customerNumber. Use this number as the base when adding new customer data. 4. The program should be able to start multiple times and add data with increasing customerNumbers. There should be no duplicated customer numbers. 5. Menu Option 2 should do the following tasks a. Prompt for a customer number to change. b. Enter the address information ( Street 1 & 2, City, State and Zipcode) c. Find the record for the customer number and replace the address information. 6. Menu Option 3 should do the following tasks a. Reset the file pointer to the beginning of the file. b. For each record in the file, display the customer number, customer name and all address information. The items isDeleted and newLine are not to be displayed.
This program will store structure data in a file called Customers.dat.
For this assignment, create a menu with the following tasks:
1. Add Data
X. 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 exist
The 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 = 203;
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.
Deliverable is a working CPP program.
Transcribed Image Text:This program will store structure data in a file called Customers.dat. For this assignment, create a menu with the following tasks: 1. Add Data X. 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 exist The 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 = 203; 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. Deliverable is a working CPP program.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY