the peolples details to be used
4
324 herold st, here, VIC 3180
John, William
4
5000.799805
51
123 Smith St, DOncaster, NSW 2891
John, william
5
5555.500000
1
121 Martin Place, Point Cook, VIC 2910
Brian, Davis
7
2000.000000
42
12 Peterson St. Fadden, ACT 2904
Peter, Smith
6
1000000.000000
0
The work
Task 1 [10 marks code correctness]
The program should be menu driven. The user should be presented with the following menu:
1. Load catalogue from file
2. Delete property from catalogue
3. Save catalogue to file
4. Search property
5. Sort and display catalogue
6. Quit
After selecting one of the above options the corresponding task should be performed. After completing the selected task, the menu should be displayed again for the user to choose from again.
Task 2 [20 marks code correctness]
Implement the load catalogue from file menu option. After selecting this option the user should be asked to enter the name of a file to be loaded. The file should then be loaded into a run-time(dynamically) allocated data structure. You should not use compile-time (static) memory allocation. You can assume the file will have the following format.
[Number of properties]
[Address of property]
[Real estate agent firstname], [Real estate agent surname]
[Number of bedrooms]
[Price of property]
[List of features in one decimal number]
?
?
[Address of property]
[Real estate agent firstname], [Real estate agent surname]
[Number of bedrooms]
[Price of property]
[List of features in one decimal number]
The ? stands for intermediate catalogue entries.
You can assume the property address string to be a maximum of 200 characters.
The firstname and surname strings have a maximum of 100 characters each.
Here is an explanation of the above fields:
[Number of properties] – This is the number of properties stored in the file
[Address of property] ? A string specifying the address of the property, the string may contain spaces, punctuation, and numbers. However the entire address is specified in one line. Hint: you can use gets to read in a whole line at a time.
[Real estate agent first name], [Real estate agent last surname] ? Two strings which do not contain spaces but are separated by a comma followed by a space.
[Number of bedrooms] – A number specifying the number of bedrooms in the property
[Price of property] – Price of the property, it may contain a decimal point.
[List of features in one decimal number] ? The binary representation of the decimal number is used to specify the existence of certain features in the property (See lecture 13 to see how to convert between positive decimal numbers and two?s complement binary number). Only the last six binary digits are used, since there are a total of six possible features. A binary value of 1 for the feature indicated the feature exists, 0 indicates the feature does not exist for the property. Below is the list of features along with their binary representation:
000001 – garage
000010 – ensuite
000100 – dishwasher
001000 – air conditioner
010000 – heating
100000 – study
So for example a property that has an ensuite, air conditioner and heating would be specified using the decimal number 26 which translates to the binary representation 011010.
Below is an example of a catalogue file that contains 2 properties:
2
32 Bugden Ave, Forest Hill, VIC 3108
Peter, Kernighan
3
602000.82
47
292 Smith St, Blackburn, ACT 3920
Amit, Chandhri
2
222292.84
38
Task 3 [15 marks code correctness]
Implement the delete property from catalogue menu option. After selecting this option the user should be asked to specify the property to be deleted using the following sub-menu:
1. Specify the property address
2. Specify real estate agent first name
3. Specify real estate agent surname
After choosing one of the above sub-menu options, the user should be asked to type in a string to be used for finding the property to be deleted. Note the specified string may match more than one property. For example if the user specifies the first name peter then there maybe more than one property with the real estate agent peter. In this case all properties that match must be deleted. Note the string has to completely match the property attribute. Partial match is not considered a match.
In the following example the user strings does not match the corresponding properties:
User types in for property address: 32 Bugden Ave, Forest Hill, VIC 3108
Actual property address: 32BugdenAve,ForestHill,VIC3108
User types in for real estate agent first name: peters
Actual real estate agent first name for property: peter
User types in for real estate agent surname: peter
Actual real estate agent surname for property: peterson
The search should be case insensitive. Therefore the following does match:
User types in for real estate agent first name: peter
Actual real estate agent first name for property: peTer
User types in for property address: 32 bugden ave, forest hill, vic 3108
Actual property address: 32 Bugden Ave, Forest Hill, VIC 3108
If more than one matching property is found then all matching properties are deleted. The program needs to free up memory that is no longer needed as a result of the deletion.
Task 4 [10 marks code correctness]
Implement the save catalogue to file menu option. After selecting this option the user should be asked to specify the name of the save file. All the catalogue data should be stored onto the specified file in the same format as the file loaded in Task 2.
Task 5 [13 marks code correctness]
Implement the search catalogue menu option. This option allows the user to search for properties that have certain features. After selecting this option the user will be asked to type in a list of features. Then the properties that contain ALL the searched features will be displayed (note this is different from the exercise 2 of lab 6 where you are asked to find all students that is at least studying one of two subjects specified by the user ). Please note you must use bitwise operators for this exercise. If bitwise operators are not used then you will get zero marks for this question. The user specifies the list of features as follows:
The list of features entered by the user is all in one line. You can assume the user inputs the list of features all in lower case. There is a comma followed by a space between each feature.
[name of feature], [name of feature], ??
Where name of feature can be one of the following:
garage
ensuite
dishwasher
air conditioner
heating
study
The properties that match the selected features are displayed as follows:
—————————————————————
Address: [Address of property]
Real estate agent: [Real estate agent firstname] [Real estate agent surname]
Number of bedrooms: [Number of bedrooms]
Price: $[Price of property]
List of features: [List of features in one decimal number]
—————————————————————
….
….
—————————————————————
Address: [Address of property]
Real estate agent: [Real estate agent firstname] [Real estate agent surname]
Number of bedrooms: [Number of bedrooms]
Price: $[Price of property]
List of features: [List of features in one decimal number]
—————————————————————
Note: [Number of properties], [Address of property], [Real estate agent firstname], [Real estate agent lastname], [Number of bedrooms], [Price of property], [List of features in one decimal number] have the same meaning as those for task 2.
Here is an example output:
—————————————————————
Address: 273 Cavalier St, Glen Waverly, VIC 2911
Real estate agent: Angela Smith
Number of bedrooms: 10
Price: $100000000
List of features: 49
—————————————————————
Address: 29 Kennon Ave, Melbourne, VIC 2831
Real estate agent: Clive Johnson
Number of bedrooms: 1
Price: $102922
List of features: 61
—————————————————————
Task 6 [20 marks code correctness]
Implement the sort and display catalogue menu option. Once this option is selected the following sub-menu is displayed:
1. Sort property by surname of real estate agent
2. Sort property by price
3. Sort property by number of bedrooms
To get full marks for this task you should design your sorting algorithm so that it uses function pointers to allow the same algorithm implementation to be used to sort for all 3 different attributes. Note the easiest way to do this is use the qsort library function in C.
After the above choice is made the properties are sorted in ascending order and displayed according to the same format as for task 5.