Day of the week

  • 4
  • Locked
Planet Terra still has "offices"—an outdated type of workspace. With current technology, there is no need for them, but earthlings tend to be nostalgic and haven't been in a hurry to eradicate them. Terrestrial office workers develop "TGIF syndrome": they constantly want to know what day of the week it is. Let's write a program for them!
You can't complete this task, because you're not signed in.
Comments (23)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Lunita
Level 4
5 February, 03:10
Fairly easy, I did it by using a lot of "if else" and the operators || and ==
DavidJugaad
Level 10
19 July 2021, 16:35
Hey guys, First, this code solution works. I´m not asking for help, but I would like to receive feedback. I´ve seen solutions of other users with swith/case, and nested ifs in the main body of the solution. Can anybody suggest me a more compact solution than mine plz? I´ve tried to give a solution following OOP paradigm wich means reuse code creating a method, and using an array to have a more easy to read code...
Samuel
Level 16 , London, United Kingdom
26 March 2021, 12:36
Either [switch/case] or [if/else] statements are excellent. Indeed there are some differences between these two, but if you can complete the task with either then thumb up!
Pahunchik
Level 8 , Moscow, Russian Federation
10 March 2021, 14:51
Hi everyone) Why it's wrong? BufferedReader str = new BufferedReader(new InputStreamReader(System.in)); String daystr = str.readLine(); int daynum = Integer.parseInt(daystr); if (daynum = 1) ---> error: int cannot be converted to boolean
Roman
Level 41
12 March 2021, 07:31
because the comparison is "=="
Shellie
Level 4 , Baltimore, United States
28 January 2021, 21:06
This question is outdated. Offices are so 2019 😋
M Till
Level 7 , San Jose, United States
24 July 2020, 22:07
try to switch up your thinking! ;) ;) ;)
Sean Nigito
Level 7 , Newark, United States
29 July 2020, 21:23
yeah a switch statement works really well
Laura
Level 7 , Lübeck, Deutschland
13 August 2020, 12:19
What is the switch statement?
Sean Nigito
Level 7 , Newark, United States
14 August 2020, 23:40
It is sort of like a chain of if else statements but looks for a specific input Here is a better explanation: https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.homeandlearn.co.uk%2Fjava%2Fjava_switch_statements.html&psig=AOvVaw2KXyPI_gGvfEmshgWQAQDH&ust=1597534748860000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPiUpevum-sCFQAAAAAdAAAAABAD
HaeWon Chung
Level 17 , Boston, United States
17 January 2020, 01:35
I was able to pass but I had to use
int a = Integer.parseInt(reader.readLine());
which I haven't learned it yet. Is there anyway to solve it without converting string into int? Or did I miss any lessons?
Skynet
Level 40 , USA
31 October 2019, 15:29
Used a more advanced code, which we have not covered so far. Created a String array, to which I added "No such day of the week" and all of the days of the week in the correct order (i.e. 8 entries in total). Then used an if statement with a condition: if the entered day of the week is higher than 0 AND less than 8, then output the entry of the array which corresponds to the entered number by index (i.e. if you entered 2, then you will get "Tuesday"). Did not need any conditions in the else statement, just the output of the first index of the array (e.g. yourArray[0]), which means that the true output will be the "No such day of the week" text, which is assigned to the first index of the array.
Steve
Level 9 , Denver, United States
23 June 2019, 12:50
I used switch,, it works fine
shabarish kumar
Level 20 , Hyderabad, India
19 May 2019, 05:28
Are we not supposed to use Switch here!