PROCEDURAL PROGRAMMING WITH C 2. (30 pts) Given that C is NOT OOP, so in this question you will try to mimic OOP state of auto inventory catalogue in Q5 using C structures. Using the ordered output...

1 answer below »
This assignment requires C and Ruby.


PROCEDURAL PROGRAMMING WITH C 2. (30 pts) Given that C is NOT OOP, so in this question you will try to mimic OOP state of auto inventory catalogue in Q5 using C structures. Using the ordered output file created using your Ruby program in Q5, write a C program that uses that output file and works according to the following description: a. Creates different structure types that corresponds to different class types that you created in Q5 b. Each structure will contain a pointer to the next structure of the same type. c. The top-level structure will additionally contain a pointer to the first structure in the level below that corresponds to one of the models of that car maker d. It reads the file and starts populating variables of the corresponding structure type and updates the linked list pointers accordingly. It will also store different vehicle listing features in the structures that it just created. e. You should also create the three functions explained in Q5: searchInventory, Add2Inventory, saveCatalogue2File. The implementation will be quite different as you will have to traverse the linked list (multi linked list in our case here) to find different listing and process them accordingly. The multi linked list of structures should look like the figure below: OBJECT ORIENTED PROGRAMMING WITH RUBY 4. (20 pts) Automated Readability Index (ARI) is used for testing readability in English text. The mathematical formula for calculating ARI in a text document is as follows: ??? = 4.71 × (?ℎ????????/????) + 0.5 × (?????/????????) − 21.43 Where: ?ℎ???????? = ∑ ???????, ??????? ??? ??????????? ????? = ∑ ?????? ????????? = ∑ ???? ????s The following table shows the educational grade level that corresponds to each ARI score: Write a Ruby method that can read any document file, count number of characters, words, and sentences and then apply the ARI formula to find out the grade level required for a person to read the opened document. For example, for the following “paragraph.txt” file: After the Lord Stanley of Preston was appointed by Queen Victoria as Governor General of Canada on June 11, 1888, he and his family became highly enthusiastic about ice hockey. Stanley was first exposed to the game at Montreal's 1889 Winter Carnival, where he saw the Montreal Victorias play the Montreal Hockey Club. The Montreal Gazette reported that he "expressed his great delight with the game of hockey and the expertise of the players". During that time, organized ice hockey in Canada was still in its infancy and only Montreal and Ottawa had anything resembling leagues. A Ruby method call: calcARI(“paragraph.txt”) should output the following: Total # of characters: 474 Total # of words: 96 Total # of sentences: 4 Automated Readability Index: 13.8 Grade level: 18-24 (college student) 5. (30 pts) In this question, you should create an auto showroom inventory catalogue using Ruby. Your program should read a car listings file which contains all available inventory details where each line contains the following 11 listing features: #km, type, transmission, stock#, Drivetrain, Status, Fuel Economy, car_maker, model, year, Trim,set_of_features examples of listing lines as follows: 65101km,Sedan,Manual,18131A,FWD,Used,5.5L/100km,Toyota,camry,SE,{AC, Heated Seats, Heated Mirrors, Keyless Entry},2010 coupe,1100km,auto,RWD, Mercedec,CLK,LX ,18FO724A,2017,{AC, Heated Seats, Heated Mirrors, Keyless Entry, Power seats},6L/100km,Used AWD,SUV,0km,auto,new,Honda,CRV,LE,19BF723A,8L/100km,2018,{Heated Seats, Heated Mirrors, Keyless Entry} Note: order of listing features varies from one line to another as it was entered by employees not trained for proper data entry. Also, assume the following listing feature possible values (case insensitive): Your program should have four methods as follows: • convertListings2Catalougue: a method that: o reads the listings file line by line o correctly recognizes and extracts different listing features o instantiates appropriate objects of different classes and subclasses that you should define to hold the listing information for different car makers, their models and trim lines available in our listings. Any parent class should have properties that count the number of listings of that maker or that model along with other common behavior or properties. In the listings examples above, you can create an object of class (car_model) and store all the listing information in that class and also update the parent (car_maker) common class properties accordingly. Note: The OOP design and choice of classes and subclasses is something that differs from one programmer to another and depends on the way you look at the problem. • searchInventory: a search method that accepts a hash as its argument and based on the combination of hash key-value pairs will perform an advanced search for all vehicles in stock that matches the criteria. For example, searchInventory( {“car_maker” => ”Mercedes”}) should display all Mercedes vehicles available. • Add2Inventory: a method that accepts a new listing as a single line of unordered listing features, add the line to the original listing file and add an appropriate object to the catalogue based on the listing features. • saveCatalogue2File: a method that traverses all created catalogue objects and stores them to an output file alphabetically according to their maker name. each listing features will follow a strict fixed order as opposed to the original file random order. For example, the original three listings will look as follows in the output file: Toyota,camry,SE,65101km,2010, Sedan, FWD, Manual, 18131A, Used,5.5L/100km, {AC, Heated Seats, Heated Mirrors, Keyless Entry} Mercedec,CLK,LX, 1100km,2017,coupe, RWD, auto, 18FO724A, Used,6L/100km,{AC, Heated Seats, Heated Mirrors, Keyless Entry, Power seats} Honda,CRV,LE,0km, 2018, SUV, AWD, auto, 19BF723A, new,8L/100km,{Heated Seats, Heated Mirrors, Keyless Entry}
Answered Same DayApr 09, 2021

Answer To: PROCEDURAL PROGRAMMING WITH C 2. (30 pts) Given that C is NOT OOP, so in this question you will try...

Abr Writing answered on Apr 12 2021
145 Votes
paragraph.txt
After the Lord Stanley of Preston was appointed by Queen Victoria as Governor General of Canada on June 11, 1888, he and his family became highly enthusiastic about ice hockey. Stanley was first ex
posed to the game at Montreal's 1889 Winter Carnival, where he saw the Montreal Victorias play the Montreal Hockey Club. The Montreal Gazette reported that he "expressed his great delight with the game of hockey and the expertise of the players". During that time, organized ice hockey in Canada was still in its infancy and only Montreal and Ottawa had anything resembling leagues.
listings.csv
65101km,Sedan,Manual,18131A,FWD,Used,5.5L/100km,Toyota,camry,SE,{AC,Heated Seats,Heated Mirrors,Keyless Entry},2010
coupe,1100km,auto,RWD,Mercedec,CLK,LX ,18FO724A,2017,{AC,Heated Seats,Heated Mirrors,Keyless Entry,Power seats},6L/100km,Used
AWD,SUV,0km,auto,new,Honda,CRV,LE,19BF723A,8L/100km,2018,{Heated Seats,Heated Mirrors,Keyless Entry}
calcARI.rb
def calcARI(file)
lines = File.readlines(file)
text = lines.join()
words = text.split.size
sentences = text.split(".").size
counted = {}
characters = text.split("")
for char in characters
if char == " " || char == "," || char == '"' || char == '.'
next
elsif counted.has_key? char
counted[char] =counted[char] + 1
else
counted[char]= 1
end
end
characters = counted.values.sum
ari = 4.41 * characters/words +
0.5 * words/sentences -
21.43
if ari < 2
age = '5-6'
grade = 'Kindergarten'
elsif ari < 3
age = '6-7'
grade = 'First/Second Grade'
elsif ari < 4
age = '7-9'
grade = 'Third Grade'
elsif ari < 5
age = '9-10'
grade = 'Fourth Grade'
elsif ari < 6
age = '10-11'
grade = 'Fifth Grade'
elsif ari < 7
age = '11-12'
grade = 'Sixth Grade'
elsif ari < 8
age = '12-13'
grade = 'Seventh Grade'
elsif ari < 9
age = '13-14'
grade = 'Eighth Grade'
elsif ari < 10
age = '14-15'
grade = 'Ninth Grade'
elsif ari < 11
age = '15-16'
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here