+ 1

can you help to solve this in java

Declare and initialize the days of the week. Print and output them using the for loop. Create a condition that if the day is Friday, print “TGIF” instead of the word “Friday”. Sample output: Monday Tuesday Wednesday Thursday TGIF Saturday Sunday

13th Feb 2022, 1:46 AM
Miss CuteđŸ„ș
Miss CuteđŸ„ș - avatar
6 Answers
+ 7
Miss CuteđŸ„ș Please specify which language you are using, and also post your attempt. That way, we can assist you by identifying where you are struggling. I would suggest you declare your items inside an array / list Iterate through the list testing each item using an IF statement. if Friday, print TGIF else print the item, (day of week)
13th Feb 2022, 2:06 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
oww sorry this is java
13th Feb 2022, 2:14 AM
Miss CuteđŸ„ș
Miss CuteđŸ„ș - avatar
+ 2
In java you can use the for each loop - it will be almost like in python )))) Java: for (String day : daysOfTheWeek) { if (day == "Fri") System.out.println("TGIF"); else System.out.println(day + "day") } Python: For day in daysOfTheWeek: If day == "Fri": print("TGIF") else: print(day + "day")
14th Feb 2022, 8:38 AM
Alex
13th Feb 2022, 2:12 AM
boneSpider
boneSpider - avatar
13th Feb 2022, 2:27 AM
boneSpider
boneSpider - avatar
+ 1
days of the week with the encapsulation principle :) https://code.sololearn.com/cS7BWxnCmkBH/?ref=app
14th Feb 2022, 10:07 AM
Alex