ASP.NET C# The body of the Model’s GetGreeting() method has been left blank. It is up to you to now insert the relevant

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

ASP.NET C# The body of the Model’s GetGreeting() method has been left blank. It is up to you to now insert the relevant

Post by answerhappygod »

ASP.NET C#
The body of the Model’s GetGreeting() method
has been left blank. It is up to you to now insert the relevant
code so that an apropriate message is displayed. The idea of
the app is that the incoming URL from the browser will specify an
integer parameter in the range 1 to 24 to represent the 24-hour
clock. Depending on the value of the parameter, the method is to
return a greeting message.
If the
parameter is between 1 – 6, the greeting message is “Go back to
sleep, Ivan Ivanov!”
Else if the parameter is between 7 –
12, the greeting message is “Good morning, Ivan Ivanov!”
Else if
the parameter is between 13 - 17, the greeting message is “Good
afternoon, Ivan Ivanov!”
Else if
the parameter is between 18 – 20, the greeting message is “Good
evening, Ivan Ivanov!”
Else if
the parameter is between 21 – 24, the greeting message is “Good
night, Ivan Ivanov!”
Else the
greeting message is "No greeting available, Ivan Ivanov!"
Think if the above logic may be implemented with a
switch construct. Your code should return a
single element of the array greeting[],
appropriately selected according to the above logic. E.g.
return greeting[0] if the
parameter is between 1 – 6.
The code needs to be inserted here:
using System;
namespace Greetings.Models
{
public class GreetingsModels
{
public class Greeting
{
private String[] greeting
= new String[] { " " };
public String
GetGreeting(int option)
{
// CODE TO
BE INSERTED
return
"Greetings!";
}
}
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply