Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

Aim:

Developing programs via functional decomposition and pointers.
On completion you should know how to:
- design a program by decomposing the problem into small functional units,
- implement a program using pointers and dynamic memory,
- produce a database program for maintaining records.

Requirements:

You are provided with an incomplete database program for accessing an electronic phone book. Your task is to firstly convert memory management from static to dynamic memory and implement the main search function. Each record in the database contains the following information:

Phone Number // 8 digit number
Family Name; // up to 20 chars
Given Name; // up to 20 chars
Street Number; // number 1..2500
Street Name // up to 30 chars
Suburb // up to 30 chars
PostCode // 4 digit number

The program is implemented in 3 files: main.cpp contains the text-menu based user interface. ass2.h contains public function prototypes. ass2.cpp contains the function definitions of the database program. Test data is provided in phone.txt.

Step 1: involves converting the program from static to dynamic memory. To do this, first convert the DB array into an array of pointers to PhoneRecords:

PhoneRecord *gPhoneRecs[cMaxRecs];

Then modify the ReadFile() function so that as records are read, dynamic memory is allocated to array elements using the new operator:

gPhoneRecs[i] = new PhoneRecord;

This statement should go just after the break statement within in the read file loop. Now convert all references to the PhoneRecord fields to ‘->'. e.g.

fin >> gPhoneRecs[i]->PostCode;

Also, complete the DisplayRecord() function for displaying records in the DB array five records at a time. (Make sure the format complies with that shown below.) Example:

Command: d
56391746 John Johns, 520 Park Lane, Oak Flats, 2532
14053398 Jill Jackson, 153 Seaview Dr, Mt Keira, 2211
70399355 Jack Hendly, 134 Parker St, Blacktown, 5933
83438529 Chris Smith, 788 Crest St, Albion Park, 2544
41878844 Joe Jones, 89 Keira Lane, Kanahooka, 2322 Display more records? y/n:

92392252 Jack Bell, 707 Cherry Lane, Waterfall, 2233
93037935 Lauren Hendly, 557 Cope St, Kanahooka, 2322
50981291 Mary Hendly, 94 Crest St, Blacktown, 5344
93220958 Jenifer Parker, 415 Park Lane, Oak Flats, 2456
23339704 Mavis Johnstone, 904 Peace Dr, Mt Keira, 2211 Display more records? y/n:

Step 2: involves implementing an AddRecord() function for adding a new record to the DB:

a adds a new record to the file

Example:

Command > a
Adding a new Record to Database...
Enter phone number: 42219999
Enter family name: Gates
Enter given name: Bill
Enter street number: 123
Enter street name: Silicon Dr
Enter suburb name: Silicon Valley
Enter postcode: 9999
A new record has been added to the database
...there are 245 records in the database

Note: The new record should be both added to the gPhoneRecs[] array and the data file. To append the record data to the end of the data file use:

fout.open(filename, ios::app); // opens file in append mode.

Step 3: involves implementing a Search() function for searching the database. The search function should request the Phone number from the user and display the matching phone number on the screen. Example:

Command > s
Enter phone number: 85332209
Jill, Dell, 779, Parker St, Smithville, 2958

Command > s
Enter phone number: 88884444
Record not found!

Also, implement a CleanUp() function for deleting all memory in the DB array when the program ends to avoid a memory leak.

Step 4: Add an erase record menu item to main.cpp e.g.:
"(e) Erase record"
and implement this function in ass2.cpp. e.g.

Command > e
Enter phone number: 88884444
88884444 has been erased from the database
...there are 244 records in the database

Attachment:- Assignment-CPP.zip

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92261342
  • Price:- $100

Guranteed 48 Hours Delivery, In Price:- $100

Have any Question?


Related Questions in Computer Engineering

Create login form to enter user name and a password textbox

Create login form to enter user name and a password textbox to enter password, and write procedure to simulate the process of triggering the login process after hitting the Enter Key.

Display the manager of the employee with the oldest project

Display the manager of the employee with the oldest project start date (start_date). (This query requires 3 nested queries, start by finding the min start_date from project, then find the emp_id from project where start_ ...

Question suppose you want to back up a huge file to a cd-r

Question : Suppose you want to back up a huge file to a CD-R. You can do this by splitting the file into smaller pieces and backup up those pieces separately. Write a utility program named FileSplitter that splits a larg ...

Solutions may require mathematical proofs tracing of

Solutions may require mathematical proofs, tracing of algorithms (displaying the calculations and values of variables for each iteration of the algorithm), algorithm design, and writing programs. The following submission ...

Suppose a firm is employing all its inputs so that the mrp

Suppose a firm is employing all its inputs so that the MRP per dollar spent on each sentence is the same. this suggest that: a) amount of each resource employed will depend on both its price and its productivity b) price ...

For the following c statement what is the corresponding

For the following C statement, what is the corresponding RISC-V assembly code? Assume that the variables f, g, h, and i are given and could be considered integers as declared in a C program. Use a minimal number of assem ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

Suppose that in responding to interrupts from io devicea

Suppose that in responding to interrupts from I/O deviceA the processor consumes 1000 cycles to perform the context switch required to transfer control to the interrupt handler. The interrupt handler takes an additional ...

Suppose the probability density function for a random

Suppose the probability density function for a random variable X equals the following:  f(x) = cx 3  for {0 (a) Solve for the value of "c" that makes this a valid pdf. (Hint: please refer to the two necessary conditions ...

Companies persue closer coordination and collaboration with

Companies persue closer coordination and collaboration with channel suppliers to better address customer needs inorder to 1) Develop human resource management activities that improve the skills , expertise and knowledge ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As