Developing programs via functional decomposition and pointer

Assignment Help Computer Engineering
Reference no: EM131452602

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: <y>

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: <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

Reference no: EM131452602

Previous Q& A

  Evaluate current or future applications of biotechnology

Biotechnology refers to the technical applications. Evaluate current or future applications of biotechnology in the fields of medicine or agriculture.

  Analyze how the company can manage these risks.

Explain what risks the company could face in entering the market in Mexico.Explain how these risks might be different than those risks faced in staying.

  How many bits are required in the control memory

Stepping motors are used to drive the two axes of an insertion machine used for electronic assembly.

  How can you revise this sentence to make it clearer

Do you see how I was able to be more direct and still express the same point? Which version is easier for you to follow?

  Discuss the important concepts and issues presented

Discuss the important concepts and issues presented in Topic One: Medical Indications, demonstrating your understanding of key ethical principles.

  Determine the accuracy and the repeatability

A two-axis NC system is used to control a machine tool table uses a bit storage capacity of 16 bits in its control memory for each axis.

  Changes shown on the t-account

Suppose that Deja owns a McDonald's franchise. She decides to move her restaurant's checking account to WellsFargo, which causes the changes shown on the follow

  Prefer zero noise from their practicing

Are the following statements true, false, or uncertain? Explain your answer in 5 lines or less.

  Advise jim on the deductibility of travel costs

LEGL602 TAXATION LAW. Advise Jim on the deductibility of travel costs in respect of the following travel: Driving from his office in the CBD to another court

  What is the firm economic profit

What is the profit-maximizing solution? What is the profit-maximizing quantity? What is the profit-maximizing price? What is the firm's economic profit?

Reviews

len1452602

4/6/2017 4:01:53 AM

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. Before submitting your files, test your program with the input provided below and save the output to a file named “output.txt”. Submit your files using the submit facility on UNIX as shown below: $ submit -u login -c CSCI251 –a2 main.cpp ass2.h ass2.cpp output.txt where 'login' is your UNIX login ID (Note: CSCI851 should also submit to –c CSCI251). Deductions will be made for untidy work or for failing to comply with the submission instructions. Requests for alternative submission arrangements will only be considered before the due date. An extension of time for the assignment submission may be granted in certain circumstances. Any request for an extension of the submission deadline must be made to the Subject Coordinator before the submission deadline. Supporting documentation must accompany the request for any extension.

Write a Review

 

Similar Q& A

  Discuss the ea component presented as part of case study

Discuss the EA component(s) presented as part of the case study: integration of IT good and services, the governance of IT good and services, securing the enterprise, IT strategy, ITIL, BYOB.

  What purpose would each feature serve for your site

Select at least three interactive features that could be added to your site. What purpose would each feature serve for your site and its visitors? How would you construct these features?

  Decision-making process

Banner advertising on the Web sites helps activate the realization that there is a gap between the reality and desired state that happens in the --------------- stage of EC purchase decision-making process.

  Explore how video games are being used by medical community

For this writing assignment, you will explore how video games are being used by the medical community. Video games (both online and apps) are a source of entertainment for individuals and groups of people.

  Assembly program

Specify the assembly language program (of equivalent binary instructions), created by a compiler from following pseudo-code program. Suppoose all variables are integer.

  How to enlarge the size of the array

How to enlarge the size of the array? Enlarge the size of the array to 25. Driver will start with 10 objects in it other than has provision for up to 15 new objects. You can use java any API.

  What would be the transmission rate

Supposed two TCP connections are present over some bottleneck link of rate R bps. Both connections have a huge file to send (in the same direction over the bottleneck link). The transmissions of the files start at the similar time. What is the tra..

  Experiment quantizers designed for different distributions

DPCM can also be used for encoding images.- Encode the Sinan image using a one-tap predictor of the form and a 2-bit quantizer. Experiment with quantizers designed for different distributions. Comment on your results.

  Calculate the revenue for the two remaining unfilled classes

Calculate the revenue for the two remaining unfilled classes (Yoga and Zumba) as described below, using absolute references to the cells in the range F5:G5:.

  1 search the web mainly ieee and acm publication databases

1. search the web mainly ieee and acm publication databases to find a recent article on a biomedical application using

  Bcnf and demonstrate how you will fix it

Find out or create an example of a violation of a normal form that you would allow, tell why you are allowing the violation and explain how you would protect against anomalies.

  What are the elf magic numbers

What primitive operations exist to support the transfer of data to and from kernel space? Do you want to implement more on top of these?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd