+ 1
Hello I have to do an exercise and something goes wrong. Here I put it and if someone could help me.
Create a function that gets a number as a parameter which represents a day of week. implement the function using switch for cases 1 - 5 : print -> "Working day"; for cases 6 - 7 : print -> "No work"; for case 7 (only) also print -> "Holy Sabatt"; for any other -> print some error...
11 Antworten
+ 3
Make the code public on the code playground then we might help
+ 2
Can you post your incorrect code so we can try to fix it?
+ 1
I post. You can see?
+ 1
Yes, you should do what @Brains said and also attach your code to your question or your reply so it is more convenient for us to help you. 😉
(In case you didn't know, attach your code by pressing the [+ Insert...] button and press [Insert Code], then select your code.)
+ 1
hi
@John Wells thank you very much for answering and helping me.
I understood my mistake.
0
https://code.sololearn.com/WcnX98jHK3yH
thanks for answering
here is the link to my code
- 1
You are missing { and } for the function. You might also add a call to test it.
- 1
You used control instead of console 3 times. You have case for 7 twice. case 6 is missing break so will also output default message.
- 1
put case 7 before case 6 without break so it prints both messages
- 1
My fixed version:
https://code.sololearn.com/W97g9g4QpQ9B/?ref=app
- 1
If you wish to reverse messages for 7, put both cases back together and use if to output the 7 only message.