/Scala_Tutorial_08

Functional Programming using Scala

Primary LanguageScala

Scala SCS 2204 - Functional Programming Scala Tutorial – 8

  1. Develop the function of interest. It consumes a deposit amount and produces the actual amount of interest that the money earns in a year. The bank pays a flat 2% for deposits of up to Rs. 20 000, a flat 4% per year for deposits of up to Rs. 200000, a flat 3.5% per year for deposits of up to Rs. 2000000, and a flat 6.5% for deposits of more than Rs. 200000. (Hint: Use Lambda functions)
  2. Write a program in PatternMatching, takes the integer input from the command line. Based on the input, write a code using match to print Negative/Zero is input when input is less than or equal to 0. Print Even number is given when input is even, and print Odd number is given when input is odd. (Hint: Use Lambda functions)
  3. Write a Scala program which defines a method named "toUpper" and it accepts a String as input parameter that is then formatted to upper case as output. Define another method named "toLower'' which accepts a String as input parameter and formats the input to lower case as output. Define another method named "formatNames" which also has an input String called "name". This method however has a parameter group which accepts a function with an input of type String and also outputs a String. This particular function will be used to apply the given format to the "name" input. You can use the test inputs for, say, "Benny", "Niroshan", "Saman" “Kumara”, and make sure that the output is as shown below. (Hint: Use Lambda functions) Output: BENNY NIroshan saman KumarA