Practice problem solving and procedural design

Assignment Help C/C++ Programming
Reference no: EM131271237

Assignment

Goal

Using the VM provided for the course, you will implement a C program to collect cat information from the user and print this information to the screen. You will practice problem solving and procedural design.

You will write code that uses functions, nested structures, double pointers, and dynamically allocated memory.

You will also continue working with the concept of a collection structure which is used to store a collection of data. The data structures that you must use are contained in a file posted in cuLearn.

Instructions

1. Design your program

You will begin with the header file posted in cuLearn, under the link a6Defs.h

Your program must use the provided data structures and function prototype, without making any changes to the existing prototype and data structures in that file. You will, however, create your own source file that uses this header file. To use the given header file, you must save that file in the same directory as your source file, and include the line:

#include "a6Defs.h"

at the top of your source file. That will copy the header file information into your source file.

Your program will prompt the user for information to populate a cat collection. This collection structure contains a statically allocated array of dynamically allocated cat structures, represented as an array of cat structure pointers. Once the cat collection is populated, your program will then print out the content of the cat collection and clean up the dynamically allocated memory.

The first step of this assignment is to break down your program into modular and reusable functions. You must examine the data structures provided, and determine which functions you need to implement. Do not put all the code in the main function!

2. Read data from the user
Your program must:
- declare an instance of a CatArrType structure
- prompt the user to enter data to populate the cat collection; there can be any number of cats, up to a maximum
- for each cat entered by the user:
  o prompt the user to enter the cat data
  o dynamically allocate an instance of a cat structure, using the initCat function defined in the given header file
  o add the new cat to the cat collection

Notes:
- the cat collection must be declared as a local variable in main
- do not prompt the user for the number of cats to be entered; you must accept input until the user enters a sentinel value determined by you
- your program must perform all basic error checking
- you must implement and call the initCat function as defined in the given header file; do not change the prototype!
- all compound data types, including structures, must be passed by reference

3. Print data to the screen
Once the cat collection has been populated with user-entered data, your program must print out the content of the collection to the screen. The information printed out must include all the fields of all structures.

4. Cleanup
When your program is done with the cat collection, you must deallocate all the dynamically allocated memory.

Constraints
- you must use the given code, data structures and function prototypes exactly as stated
- do not use any global variables
- your program must be correctly designed and separated into functions
- your program must reuse functions everywhere possible
- your program must be thoroughly commented
- your program must perform all basic error checking
- do not leave any memory leaks!

Attachment:- a6Defs.rar

Verified Expert

In this program they asked to write a C program that includes a header a6Defs.h. This header file contains the structure information. They asked to write the C program without making any changes to the existing prototype and data structures information in the header file. The init() funtion declaration in header file is defined in the C program. Together with this function three functions are written namely initialize() - to create the cat array list, print()- to print the cat array list, uninitialized - to deallocate the memory used.

Reference no: EM131271237

Questions Cloud

People electric and municipal energy : Suppose two utilities, People's Electric and Municipal Energy, each produce 100 tons of pollution per year. The government has a goal of eliminating half the pollution, and in turn, provides 50 pollution permits to each utility.
Describe the local economy stage in the business cycle : Describe the current global economic conditions and their effect on local macroeconomic indicators for your good or service. Describe the local economy's stage in the business cycle
Advertising is not and could never be a science : ‘Advertising is not and could never be a science. At best it is managed art.' Discuss this statement using examples to illustrate why you agree or disagree.
How much output will each firm produce : a) How much output will each firm produce? b) What will be the market price? c) How many firms will there be in long run equilibrium?
Practice problem solving and procedural design : COMP 2401 - Implement a C program to collect cat information from the user and print this information to the screen. You will practice problem solving and procedural design.
Highlight the differences between advertising and publicity : Explain the characteristics that distinguish advertising from other elements of the marketing communications mix. In particular highlight the differences between advertising and publicity.
Make a thermodynamic analysis of this process : If the higher-pressure steam expands in a turbine of 78% efficiency and the lowerpressure steam is compressed in a machine of 75% efficiency. Make a thermodynamic analysis of this process.
Why context of advertising makes advertising important : Return on customer investment is more important a measure than the effects of communication on behaviour'. Explain what this means.
Application such risk metrics as var and es : Describe and show application such risk metrics as VaR and ES (expected shortfall) using historical and parametric approach.

Reviews

inf1271237

11/11/2016 4:58:17 AM

Thanks for the work and explained report. through this i could understand how the code is implemented. it made my life easier. thanks for getting me good grades.

len1271237

11/9/2016 2:48:10 AM

Grading Marking components: • 2 marks: program design • 2 marks: correctly prompting the user for cat data • 2 marks: correctly allocating and initializing each cat structure with user-entered data • 1 mark: correctly adding each cat structure to the cat array • 2 marks: correctly printing out the cat array • 1 mark: correctly deallocating all dynamically allocated memory Deductions: • Packaging errors: o 10% for missing readme • Major programming and design errors: o 50% of a marking component that uses global variables o 50% of a marking component that consistently fails to use correct design principles, including separate functions o 50% of a marking component that consistently fails to pass compound data types by reference o 50% of a marking component where unauthorized changes have been made to provided code, data structures, or prototypes • Minor programming errors: o 10% for consistently missing comments or other bad style o 10% for consistently failing to perform basic error checking o 10% for memory leaks

len1271237

11/9/2016 2:47:16 AM

Constraints • you must use the given code, data structures and function prototypes exactly as stated • do not use any global variables • your program must be correctly designed and separated into functions • your program must reuse functions everywhere possible • your program must be thoroughly commented • your program must perform all basic error checking • do not leave any memory leaks! Submission You will submit in cuLearn, before the due date and time, one tar file that includes all the following: • all source code, including the code provided, if applicable • a readme file that includes: o a preamble (program author, purpose, list of source/header/data files) o the exact compilation command o launching and operating instructions

len1271237

11/9/2016 2:47:05 AM

Taking advantage of my "good discount". i prefer to have it in 24 hours so that a repeat of what happened for the last assignment doesn't occur - Using the VM provided for the course, you will implement a C program to collect cat information from the user and print this information to the screen. You will practice problem solving and procedural design. You will write code that uses functions, nested structures, double pointers, and dynamically allocated memory. You will also continue working with the concept of a collection structure which is used to store a collection of data. The data structures that you must use are contained in a file posted in cuLearn.

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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