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

  Optimization is to add a sorting algorithm

The second optimization is to add a sorting algorithm. Each time you add an item to the array (from disk or from keyboard), you call a function called SortMyArray(), which use the bubble sorting algorithm to sort the array in the ascending order, ..

  Develop gui layout

You are also required to develop your GUI layout that is similar to the screenshot below. You are not expected to have the locations and size of each control correct to the last pixel, however the relative position of the controls is to be maintai..

  Write an array implementation of self-adjusting lists

Write an array implementation of self-adjusting lists. In a self-adjusting list, all insertions are performed at the front - Write a linked list implementation of self-adjusting lists.

  Linked list with first node pointer p.

Complete the code for a function that replaces each occurrence of value x by value y in a linked list with first node pointer p.

  Write a java program

Write a JAVA program that will input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds eight hours add 30% to each excess hours as overtime rate.

  How the project teams and coaches master agile methodology

Analyze how the project teams and coaches master the agile methodology to solve business problems. Highlight the one that you believe is the most effective and support your answer.

  Declare and define constructor

Declare and define constructors and Declare and define destructors - Describe what is an attribute or data member of a class

  Declare an array of integers

Declare an array of 10 integers and initialize its elements to the following values: -10; -8; -6; -4; -2; 0; 2; 4; 6;8;10

  Write a program that right-justifies text

Write a program that right-justifies text. It should read and echo a sequence of left-justified lines and then print them in right-justified format.

  Write program which prompts user to enter numbers

Write down the program which prompts the user to enter numbers, findsout how many positive and negative values have been entered, and calculates sum and average of numbers entered.

  Find the equation of the line tangent to the graph

Find the equation of the line tangent to the graph of f(x) = (x^2 +1)/ sqrt(x)  at (1,2). Use the definition of derivative instead of derivative rules.

  Develop and test a website for the new look beauty salon

Develop and test a website for the New Look Beauty Salon - critically explore the work you have done to produce your Project.

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