Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I need help with the following in Eelang coding. thank you... In the text editor of your choosing create a file labo5.erl and write

Hi I need help with the following in Eelang coding.

thank you...

image text in transcribed

image text in transcribed

In the text editor of your choosing create a file labo5.erl and write function definitions described below - make sure you use the exact same names as indicated in function descriptions. Instead of exporting each function one by one, use command-compile(export_all) at the top of your file that will export all functions together. Download the file labo5_tests.erl, add Erlang unit test library to it, and as you work on your solutions, write unit tests for your functions (unit tests for the first three functions are provided in the test file and for the last 2 functions in this description - note that copying and pasting from the description may introduce invisible characters in which case it is better to re-type the tests). 1. Function money that that takes two tuples, where each tuple represents a money object (each tuple consists of 2 values: dollars and cents) and calculates and returns a new tuple that constitutes the addition of the incoming money objects (dollars + dollars, cents + cents). Assume valid positive integers will be passed and do NOT error check. Normalize the values, i.e. if the cents addition results in a value > 99, adjust dollars and cents properly (hint: to pattern match a function on a tuple consisting of 2 elements, you can use function Name ({X, Y}) -> ... type of a syntax) 2. Function is older that takes two dates (each date is a 3-int tuple dd, mm, yyyy) and evaluates to true or false. It evaluates to true if the first argument is a date that comes before the second argument(e.g. 30/3/2012 comes before 1/4/2012, hence a person born on 30/3/2012 is older). (If two dates are the same, the result is false.). Assume the user of your function will enter valid input. Think about how you can use relational operators on entire tuples to simplify processing instead of writing nested ifs 3. Function find Ceiling that takes a list of numbers and returns the modified list constructed by applying the function ceiling to each incoming list element. For example, if original list contains (1.9, 2.1, 3.5), then the resulting list will contain (2.0, 3.0, 4.0]; you are NOT allowed to use ++ or built-in functions or list comprehension (you should use the cons operator to build the new list; you are allowed to use math:ceil though) 4. Function my Min that takes a list and returns its minimum value-use tail recursion to find list minimum and return an atom empty_list if a list is empty; you are NOT allowed to use built-in functions; add appropriate test cases to the test file that use assertEqual macro 5. Function remove Div3 that takes a list of numbers and returns the original list with all values divisible by 3 removed, e.g. if the original list contains [0, 1, 2, -3,6], then [1, 2] is returned; you are NOT allowed to use built-in functions or list comprehension; add appropriate test cases to the test file that use true matching pattern (i.e. the other method that does NOT use assertEqual) 6. Function calculateBill that takes a list of tuples, where a tuple is of the form name, price, tax rate, and returns a list of tuples, where each tuple is of the form name, total, -module(lab05_tests). money_1_test() -> ?assertEqual({8, 30}, labo5: money({3, 20}, {5, 10})). money_2_test() -> ?assertEqual({9, 0}, lab05:money({3, 20}, {5, 80})). money_3_test() -> ?assertEqual({9, 98}, lab05: money({3, 99}, {5, 99})). isolder_1_test() -> false = labo:isolder({10, 3, 2016}, {10, 3, 2016}). isolder_2_test() -> true = labo5: isolder({10, 3, 2016}, {11, 3, 2016}). isolder_3_test true = lab05:isolder({10, 1, 2016}, {10, 2, 2016}). isolder_4_test() -> false = lab05: isolder({10, 3, 2016}, {11, 2, 2016}). isolder_5_test() -> true = labo5:isolder({10, 12, 2015}, {10, 12, 2016}). isolder_6_test() -> true = lab05:isolder({11, 12, 2015}, {10, 12, 2016}). isolder_7_test() -> true = labo5:isolder({12, 11, 2016}, {12, 10, 2017}). isolder_8_test() -> true = lab05: isolder({12, 10, 2016}, {11, 3, 2017}). findCeil_1_test() -> [] = labo5: findCeiling([]). findCeil_2_test() -> [2.0, 3.0, 4.0, -1.0] = lab05:findCeiling([1.9,2.1,3.5,-1.3]). findCeil_3_test() -> [2.0] labos: findCeiling((1.2]). findCeil_4_test() -> In the text editor of your choosing create a file labo5.erl and write function definitions described below - make sure you use the exact same names as indicated in function descriptions. Instead of exporting each function one by one, use command-compile(export_all) at the top of your file that will export all functions together. Download the file labo5_tests.erl, add Erlang unit test library to it, and as you work on your solutions, write unit tests for your functions (unit tests for the first three functions are provided in the test file and for the last 2 functions in this description - note that copying and pasting from the description may introduce invisible characters in which case it is better to re-type the tests). 1. Function money that that takes two tuples, where each tuple represents a money object (each tuple consists of 2 values: dollars and cents) and calculates and returns a new tuple that constitutes the addition of the incoming money objects (dollars + dollars, cents + cents). Assume valid positive integers will be passed and do NOT error check. Normalize the values, i.e. if the cents addition results in a value > 99, adjust dollars and cents properly (hint: to pattern match a function on a tuple consisting of 2 elements, you can use function Name ({X, Y}) -> ... type of a syntax) 2. Function is older that takes two dates (each date is a 3-int tuple dd, mm, yyyy) and evaluates to true or false. It evaluates to true if the first argument is a date that comes before the second argument(e.g. 30/3/2012 comes before 1/4/2012, hence a person born on 30/3/2012 is older). (If two dates are the same, the result is false.). Assume the user of your function will enter valid input. Think about how you can use relational operators on entire tuples to simplify processing instead of writing nested ifs 3. Function find Ceiling that takes a list of numbers and returns the modified list constructed by applying the function ceiling to each incoming list element. For example, if original list contains (1.9, 2.1, 3.5), then the resulting list will contain (2.0, 3.0, 4.0]; you are NOT allowed to use ++ or built-in functions or list comprehension (you should use the cons operator to build the new list; you are allowed to use math:ceil though) 4. Function my Min that takes a list and returns its minimum value-use tail recursion to find list minimum and return an atom empty_list if a list is empty; you are NOT allowed to use built-in functions; add appropriate test cases to the test file that use assertEqual macro 5. Function remove Div3 that takes a list of numbers and returns the original list with all values divisible by 3 removed, e.g. if the original list contains [0, 1, 2, -3,6], then [1, 2] is returned; you are NOT allowed to use built-in functions or list comprehension; add appropriate test cases to the test file that use true matching pattern (i.e. the other method that does NOT use assertEqual) 6. Function calculateBill that takes a list of tuples, where a tuple is of the form name, price, tax rate, and returns a list of tuples, where each tuple is of the form name, total, -module(lab05_tests). money_1_test() -> ?assertEqual({8, 30}, labo5: money({3, 20}, {5, 10})). money_2_test() -> ?assertEqual({9, 0}, lab05:money({3, 20}, {5, 80})). money_3_test() -> ?assertEqual({9, 98}, lab05: money({3, 99}, {5, 99})). isolder_1_test() -> false = labo:isolder({10, 3, 2016}, {10, 3, 2016}). isolder_2_test() -> true = labo5: isolder({10, 3, 2016}, {11, 3, 2016}). isolder_3_test true = lab05:isolder({10, 1, 2016}, {10, 2, 2016}). isolder_4_test() -> false = lab05: isolder({10, 3, 2016}, {11, 2, 2016}). isolder_5_test() -> true = labo5:isolder({10, 12, 2015}, {10, 12, 2016}). isolder_6_test() -> true = lab05:isolder({11, 12, 2015}, {10, 12, 2016}). isolder_7_test() -> true = labo5:isolder({12, 11, 2016}, {12, 10, 2017}). isolder_8_test() -> true = lab05: isolder({12, 10, 2016}, {11, 3, 2017}). findCeil_1_test() -> [] = labo5: findCeiling([]). findCeil_2_test() -> [2.0, 3.0, 4.0, -1.0] = lab05:findCeiling([1.9,2.1,3.5,-1.3]). findCeil_3_test() -> [2.0] labos: findCeiling((1.2]). findCeil_4_test() ->

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

25 Vba Macros For Data Analysis In Microsoft Excel

Authors: Klemens Nguyen

1st Edition

B0CNSXYMTC, 979-8868455629

More Books

Students also viewed these Databases questions

Question

Can his EI be developed and enhanced?

Answered: 1 week ago

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is human nature?

Answered: 1 week ago