subject

1. In this lab, you will use 5 different programming languages to solve the same problem: Write and use a generic sort function. This function should be able to sort values of any type that has some notion of order. The values to sort could be integers, floating point numbers, strings, pairs of values (say a string and a number), etc. 2. Write a console application in each of these 5 languages: C, C++, C#, Python and Haskell.
3. Each application has to use the following data:
The sequence of floating point numbers: 645.32, 37.40, 76.30, 5.40, -34.23, 1.11, -34.94, 23.37, 635.46, -876.22, 467.73, 62.26
The following sequence of people with name and age of each person. The name is a string and the age an integer: Hal, 20; Susann, 31; Dwight 19; Kassandra, 21; Lawrence, 25; Cindy, 22; Cory, 27; Mac, 19; Romana, 27; Doretha, 32; Danna, 20; Zara, 23; Rosalyn, 26; Risa, 24; Benny, 28; Juan, 33; Natalie, 25
Use appropriate data structures to represent the data above in each of the 5 languages and define the variables numbers and people, respectively.
4. Write one generic sort function in each of the 5 languages. Hints:
(i) The objective of this assignment is to understand generics (not sorting). You can use the sort functions from Lab Assignment 1 or just use a sort function provided in some standard library for the respective language.
(ii) C doesn’t provide any generics. However, a void*can be used to point to any value.
(iii) One way to specify an order on a type is to define a comparison function that compares two values. This comparison function could be an argument to your sort function. Some languages might provide predefined comparison functions.
(iv) Try to use everything we learned about these different programing languages, e. g., Python uses duck-typing, Haskell uses the type-class Ord to express order on a type, LINQ in C# includes the orderby operator, etc.
5. Use your generic sort function to
(i) sort numbers ascending by numerical value,
(ii) sort people alphabetically (lexicographically) by name, and to
(iii) sort people descending by age, where people of the same age should be sorted alphabetically (lexicographically).
6. The point here is to use the same function to do all 3 different sort operations. Try to reuse as much of your code and focus on clarity and brevity.
7. Write a main function in each of the 5 languages that will print out the results to the console.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:00
How should you set the ohms adjust control on a multitester of analog vom, for resistance measurements?
Answers: 1
question
Computers and Technology, 22.06.2019 14:30
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Word vocabulary words: print, proofread, status line, graphics, font effects, left margin, justification, line spacing, copy/paste, data. review words: font point, bold, save, center, error. fill in the correct word for the definition and then transfer the letters to the appropriate spot by number. some numbers will be found multiple times. you will end up with a quotation about…… what else? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 k 16 17 18 19 20 21 22 23 24 25 8 27 28 29 w 31 32 k 34 35 36 w h 39 40 41 42 8 44 45 46 47 48 49 50 51 52 53 54 55 .1. a software function that records keystrokes on a disk or drive so information can be 5 4 52 9 later retrieved. p n 2. to produce a paper copy of information. 10 7 12u n 3. a display that shows the location of the cursor, pages, etc. 45 46 18 27 36 20 42p4. pictures or images, located in clip art or other files. 6 24 44 28 34 49 555. any mis-stroke of a key. 47 41 48 2 10 n6. allows major changes to the font such as shadow, emboss, etc. 21 25 46 35 23 21 29 14 22 17 n7. a feature that centers lines of text horizontally. 49 53 46 9 51 p8. size of the font 31 16 22 b l 9. a feature that prints designated text darker than the rest to add emphasis. 32 3 . p10. to compare copy on a display screen or printout to the original 24 39 25 23 54 9 50 3 and correct errors. j un 11. a feature that allows text to be aligned at the left 11 12 7 21 16 49 40 46 34 2 and right margins. leftn 12. amount of blank space on the left side of the paper. 8 18 41 6 34 linen 13. number of blank lines between lines of text. 17 4 49 13 1914. any information inputted into the computer. 3 4 46 44 p /p15. feature that duplicates text from one location and places it in another.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value.a member function called setscore that accepts a parameter and assigns it to score . the function returns no value.a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
You know the right answer?
1. In this lab, you will use 5 different programming languages to solve the same problem: Write and...
Questions
question
Social Studies, 12.02.2021 08:40
question
English, 12.02.2021 08:40
question
History, 12.02.2021 08:40
Questions on the website: 13722367