trying to solve volunteer teams in javascript | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

trying to solve volunteer teams in javascript

how do i get my code to output 0 if no additional member is needed Volunteers have been divided into 5 groups with equal number of members. If any group has fewer than 5 people, more volunteers must be recruited to fill the empty spots. Write a program that takes the number of volunteers and outputs to the console how many volunteers need to be hired to have 5 equal groups. Sample Input 24 Sample Output 1 Explanation The nearest number to 24 that is multiple of 5 is 25, so we need 1 more volunteer (24+1=25) to get 5 equal groups. my attempt function main() { var numberVolunteers = parseInt(readLine(), 10) // Your code here if var x=5-(numberVolunteers %5); console.log(x); }

29th Apr 2021, 11:04 AM
Simisola Osinowo
Simisola Osinowo - avatar
6 Respuestas
+ 1
So us you attempt code so we can go through your code and fix it.
29th Apr 2021, 11:06 AM
Sudarshan Rai
Sudarshan Rai - avatar
0
if(x == 5) x = 0;
29th Apr 2021, 11:09 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
CarrieForle How do i add it to the code
29th Apr 2021, 11:10 AM
Simisola Osinowo
Simisola Osinowo - avatar
- 1
Simisola Osinowo Think about it yourself. It's not hard to find where to place.
29th Apr 2021, 11:16 AM
你知道規則,我也是
你知道規則,我也是 - avatar
- 2
Sudarshan Rai function main() { var numberVolunteers = parseInt(readLine(), 10) // Your code here if var x=5-(numberVolunteers %5); console.log(x); }
29th Apr 2021, 11:09 AM
Simisola Osinowo
Simisola Osinowo - avatar
- 3
function main() { var numberVolunteers = parseInt(readLine(), 10) var remainder = numberVolunteers % 5 var difference = 5 - remainder console.log(difference) }
13th Jan 2022, 5:16 AM
Future