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); }
6 Respuestas
+ 1
So us you attempt code so we can go through your code and fix it.
0
if(x == 5) x = 0;
0
CarrieForle
How do i add it to the code
- 1
Simisola Osinowo Think about it yourself. It's not hard to find where to place.
- 2
Sudarshan Rai
function main() {
var numberVolunteers = parseInt(readLine(), 10)
// Your code here
if var x=5-(numberVolunteers %5);
console.log(x);
}
- 3
function main() {
var numberVolunteers = parseInt(readLine(), 10)
var remainder = numberVolunteers % 5
var difference = 5 - remainder
console.log(difference)
}