Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program that will loop and prompt to enter the highlighted data items in the structure below. This is every item except customerNumber ,

Create a program that will loop and 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 ' '. The item newLine is a convenient item that is there to assist in viewing the contents of the file in Notepad.exe.

The item customerNumber should start at 0 and increase by 1 for every record written.

Once the data in the structure is loaded, write it to the file "Customers.dat" and prompt to continue. If the reply is to not continue, close the file and exit.

The file "Customers.dat" must be opened in Binary mode.
 Deliverable is a working CPP program. 

Copy Assignment 1 to Assignment 2. Relabel this assignment to be Assignment 2.

1. Modify this program to open the file "Customers.dat" so that all data is written to the end of the file AND to allow the file to be read.

2. 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 - do not assume the last record in the file is the largest number. Use this number as the base when adding new customer data.

3. Display the customer number calculated for the customer number that is receiving input.

4. The program needs to create the Customers.dat file if it does not exist.

5. The program should be able to start multiple times and add data with increasing customerNumbers. There should be no duplicated customer numbers.

Deliverable is a working CPP file and psuedoCode for the getLargestCustomerNumber method.

Copy Assignment 2 to Assignment 3. Relabel this assignment to be Assignment 3.

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.

Update: Deliverable is the CPP file only, but you may want to do your own pseudo code to help with this assignment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions