Cst8234 - c programming lab assignment - write a program eg


C Programming Lab Assignment -

Programming Exercise - The purpose of this lab is to

  • Demonstrate that you can create and manipulate structures, using pointers.
  • Demonstrate that you can sort an array of structures, using appropriate comparison functions.

Statement of Problem

Write a program (e.g., 'lab4.c') that generates a sorted list of rental properties.

Each property will be implemented as a structure that has members that record the street name, the street number, the number of bedrooms, and the monthly rent.

Using a typedef to simplify naming your struct is a good idea, but not mandatory. You will initialize a 12-element array of these structs. You will provide your own (fictitious) street names and numbers, but will randomly generate the number of bedrooms (1-4) and the rent (800-1200, in one hundred dollar increments). The random numbers must vary each time you run the program. Three of your rental properties must use exactly these addresses ( "24 Sussex Drive", "1 Sussex Drive", and "5 Sussex Drive"), and two of them must exist on another street. All the other properties can exist on their own streets.

You'll need a function to print a summary of each rental property, which will be used to print out lists. This function should use fixed-width columns (as per earlier labs) to make the list is easy to read (i.e., by having the rents for each property all aligned in a single column, ditto for the number of bedrooms). You will then print out the list three times, with the following sorting criteria:

1. Sorted by number of bedrooms, increasing. If there are two or more rental properties with the same number of bedrooms, then those properties will be ordered by the monthly rent, increasing.

2. Sorted by rent, increasing. If there are two or more rental properties with the same monthly rent, then those properties will be ordered by the number of bedrooms, increasing.

3. Sorted by street address, increasing. The sorting is by street name first, then street number (e.g., "5 Sussex Drive" and "24 Sussex Drive" come before "1 Wellington Avenue") You will add an appropriate header before each list, as demonstrated in the following sample output.

Please check that you've satisfied the following submission requirements -

1. Did you make sure that you have a header comment in your source files?

2. Did you confirm that your zipped submission is a ".zip" file (not a '.rar' or '.tar.gz' or '.7z' file)?

3. Did you zip up a folder that includes your user name, and the lab/assignment indicator? I.e., if you open up your own zipped submission, you should see a folder called (for example) "smit9112_L4". If you just see file(s), you've done it wrong, and you'll need to go to the parent folder, and try zipping your lab folder.

4. Did you remove all the unnecessary files from the folder contained in your zipped submission?

I.e., you open up your own zipped submission, and click on the folder called (for example) "smit9112_L4", you should see just your makefile and your source files (e.g., lab4.c).

5. Is your makefile actually called 'makefile' or 'Makefile' (without any filename extensions?)

Attachment:- Assignment File.rar

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Cst8234 - c programming lab assignment - write a program eg
Reference No:- TGS02765583

Now Priced at $30 (50% Discount)

Recommended (91%)

Rated (4.3/5)