Write a function named WeekDay() making use of select case, the function will receive a single argument containing a STRING (days Monday - Sunday)

46 views Asked by At

Use Scilab answer the following questions: Paste both your function code, and console output demonstrating the features of the function. Write a function named WeekDay() making use of select case, the function will receive a single argument containing a STRING (days Monday - Sunday) and print a corresponding number and return an integer which is the matching week day name based on the following pairing: 1 : Monday 2 : Tuesday 3 : Wednesday 4 : Thursday 5 : Friday 6 : Saturday 7: Sunday The function will also give the same result regardless of case of the argument string (i.e. Monday, and Monday and MONDAY will all be treated equally). Sample output: --> WeekDay('Tuesday') ans = 2

I am unable to solve it

1

There are 1 answers

0
ramesh k On

WeekDay() is a function it will accept one parameter as Date and it returns weekday value.

You can try something like this. SELECT case WEEKDAY(NOW()) when 'Monday' then 1 when 'Tuesday' then 2 when 'Wednesday' then 3 when 'Thursday' then 4 when 'Friday' then 5 when 'Saturday' then 6 when 'Sunday' then END