Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method that returns a message based on the day of the week and the natur

ID: 2247506 • Letter: W

Question

Write a method that returns a message based on the day of the week and the nature of the weather. If the day of the week is Monday, Tuesday or Wednesday and regardless of the weather, then the message is "It is early in the week, have an early night" If the day of the week is Thursday or Friday and the weather is good, then the message is "Go grab a coffee", else the message is "Go shopping" If the day of the week is Saturday or Sunday and the weather is good, then the message is "Go on a picnic", else the message is "Do some work around the house" whatToDo("Tuesday", true) rightarrow It is early in the week, have an early night whatToDo("Thursday", false) rightarrow Go Shopping whatToDo("Saturday", true) rightarrow Go on a picnic whatToDo("Sunday", false) rightarrow Do some work around the house For example: Test String dayofWeek = "Friday": boolean goodWeather = true: System.out.println("What will I do: " + whatToDo(dayOfWeek, goodWeather)): Result What will I do: Go grab a coffee

Explanation / Answer


Hello, I wrote this program for you, just as you want,
You can read the comments given inside the program to understand input output flow.

If you further have any question about it then please comment. Thank you

public class MyClass {
    public static void main(String args[]) {

//input are given from here
        String dayOfWeek="Friday";
        boolean goodWeather=false;
        System.out.println("What will I do: " + whatToDo(dayOfWeek,goodWeather));
    }

// we prepared this function to give output as per specification, this function will return as String type
    public static String whatToDo(String dayOfWeek,boolean goodWeather)
    {
        if(dayOfWeek=="Monday" || dayOfWeek=="Tuesday" || dayOfWeek=="Wednesday")
        {
            return "It is early in the week, have an early night";
        }else if((dayOfWeek=="Thursday" || dayOfWeek=="Friday") && goodWeather==true)
        {
            return "Go grab a coffee";
        }else if((dayOfWeek=="Thursday" || dayOfWeek=="Friday") && goodWeather==false)
        {
            return "Go shopping";
        }else if((dayOfWeek=="Saturday" || dayOfWeek=="Sunday") && goodWeather==true)
        {
            return "Go on a picnic";
        }else if((dayOfWeek=="Saturday" || dayOfWeek=="Sunday") && goodWeather==false)
        {
            return "Do some work around the house";
        }
        return null;
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote