Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Scala - Assessment - Display Greeting Message

Let's take a look at a program which will return different greeting messages according to the time of the day.

We will write a Scala program with the main class name of Greet having a function named greet which would return different greeting messages as described below, according to the time input to the function.

Input time - 4 to till before 12 : Message Output - "Good Morning"
Input time - 12 to till before 16 : Message Output - "Good Afternoon"
Input time - 16 to till before 21 : Message Output - "Good Evening"
Input time - 21 to till before 4 : Message Output - "Good Night"

Example Usage:

If we execute Greet.greet(5), then it should return "Good Morning" If we execute Greet.greet(12), then it should return "Good Afternoon" and so on...

  • Write the code in Jupyter and press Shift + Enter.

  • Test the function with various inputs to make sure that it is returning the outputs as per requirements.

  • Click on "Submit Answer".

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...