C++ Program Assignment 1 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;

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

Assignment 1

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.

Assignment 2:

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

        1. Prompt for a customer number to change.

        2. Enter the address information ( Street 1 & 2, City , State and Zipcode)

        3. Find the record for the customer number and replace the address information.

    6. Menu Option 3 should do the following tasks

        1. Reset the file pointer to the beginning of the file.

        2. 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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 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