5.3 problem and solution

All right! We’ll do another challenge. The challenge is to write a method with the name "Weekday" for example. And that takes a parameter. int day The method should not return any value. Using a switch statement. Display the days of the week for example "Sunday", "Monday".... Until "Saturday". If the parameter "int day" is 0, 1..., Up to 6. For example, box 0 is "Sunday" and box 1 is "Monday"... Until "Saturday". Otherwise, if we put another number for example 7, it will be an invalid number, so we put "Invalid day" So are you ready? It’s gone! So how was it? I hope you managed to find a solution. Now let’s do it together! You can create a new project I did. So we’ll come here. After crochet the "hand" method. Then we write Private Static void "JourDelaSemaine" In parentheses int day. Then we write "switch" In parentheses "day". case 0 Displays "Sunday", a break. case 1 Displays "Monday". break case 2 Displays "Tuesday". break case 3 Poster "Wednesday" break case 4 Poster "Thursday". break case 5 Poster "Friday". break. Case 6: poster "Saturday". break Default Show "invalid day", if the person enters 7 for example. Now, what I’m going to do is call this method, in the "main" method. We’ll try it with different parameters to make sure it works. So, "JourdDelaSemaine". In parentheses 7. Then we execute the code And as we can see, it is well written "invalid day" Now, we will try it with 0 up to 6. So "Sunday" to "Saturday". We have the results. And that was it for this challenge! I hope you managed to do it and that it wasn’t too hard. Come on! We’ll meet at the next meeting.