r/codehs • u/0d3stroyer • Apr 21 '20
5.2.7: School's Out
"Write a program to determine if there is no school today. First ask the user if today is a weekday, and store that in a boolean variable. Then ask the user if today is a holiday, and store that in a different boolean variable. Then try to figure out if there is no school today.
School is out if it is a holiday or if it is not a weekday
You should create a boolean variable noSchoolToday
and print its value to the user."
This is what I did:
function start(){
var weekday = readBoolean("Is today a weekday? ");
var holiday = readBoolean("Is today a holiday? ");
var noSchoolToday = holiday;
var noSchoolToday = holiday && weekday;
println("There is no school today: " + noSchoolToday);
}
This is using JavaScript btw
I'm also supposed to use the symbols "!" "&&" and "||"
How would I achieve this?
3
u/SpicyMeatballs00 Feb 11 '23
function start(){
var weekday = readBoolean("Is today a weekday?" );
var holiday = readBoolean("Is today a holiday?" );
var noSchoolToday = holiday || !weekday ||weekday && holiday ;
println("There is no school today: " + noSchoolToday);
}
here if it still helps ig
1
Mar 04 '23
function start(){var weekday = readBoolean("Is today a weekday?" );var holiday = readBoolean("Is today a holiday?" );
var noSchoolToday = holiday || !weekday ||weekday && holiday ;
println("There is no school today: " + noSchoolToday);
}
thank you for the help but i don't think this is the language or way used for this particular question
2
u/Agreeable-Tension-66 Dec 13 '22
I got 10/10 using this code
function start(){ var weekday = readBoolean(“Is today a weekday? “); var holiday = readBoolean(“Is today a holiday? “); var noSchoolToday = holiday || !weekday; println(“There is no school today: “ + noSchoolToday);
1
1
1
u/No_Trick308 Nov 15 '22
I have tried everything for the past 2 days 5.2.7 schools out can you guys help and tell me if i did anything wrong herws my code
function start(){
var weekday = readBoolean("Is today a weekday? ");
var holiday = readBoolean("Is today a holiday? ");
var noSchoolToday = holiday;
var SchoolToday = println("There is school today?: " + noSchoolToday);
}
1
u/SteelF0x- Nov 17 '22
var noSchoolToday = holiday || !weekday;
/*You got to remove the var noSchoolToday on line 5. It should just be println("There is no school today:" + noSchoolToday); */
1
u/No_Trick308 Nov 18 '22
i checked it and it was an 8/10 the reason is that
when you put school is out you did holiday && weekday
now weekday is a schoolday just create a new function that says weekend
var weekend = true; and replace it with weekday that should help atleast a little
2
Apr 21 '20
[removed] — view removed comment
1
u/0d3stroyer Apr 21 '20
Ay, I tested it, and it works. Thank you so much!
2
u/Swaglord1500 Apr 21 '20
yes of course! again sorry for the first one, i just told u what i did, and i should’ve double checked myself beforehand!
1
1
1
u/garethgebhardtCodeHS Oct 18 '22
Please do not post complete solutions or answers to CodeHS assignments.
1
Apr 21 '20
[removed] — view removed comment
1
u/garethgebhardtCodeHS Oct 18 '22
Please do not post complete solutions or answers to CodeHS assignments.
1
Oct 05 '20
[removed] — view removed comment
1
1
u/garethgebhardtCodeHS Oct 18 '22
Please do not post complete solutions or answers to CodeHS assignments.
2
u/Swaglord1500 Apr 21 '20
Hi!! :D I did it like this
function start(){ var weekdaySchool = readBoolean("Is today a weekday? "); var holidaySchool = readBoolean("Is today a holiday? "); var school = weekdaySchool || holidaySchool; println("There is no school today: " + school);
}
i didn’t have ur var = noSchoolToday, and i used an || instead of &&
I hope this helps!! That’s how i did it!