Write a statement that increments (adds 1 to) one and only one of these five variables : reverseDrivers parkedDrivers slowDrivers safeDrivers speeders . The variable speed determines which of the five is incremented as follows: The statement increments reverseDrivers if speed is less than 0 , increments parkedDrivers if speed is less than 1 , increments slowDrivers if speed is less than 40 , increments safeDrivers if speed is less than or equal to 65 , and otherwise increments speeders .

LANGUAGE: C++

CHALLENGE:

Write a statement that increments (adds 1 to) one and only one of these five variables : reverseDrivers parkedDrivers slowDrivers safeDrivers speeders . The variable speed determines which of the five is incremented as follows: The statement increments reverseDrivers if speed is less than 0 , increments parkedDrivers if speed is less than 1 , increments slowDrivers if speed is less than 40 , increments safeDrivers if speed is less than or equal to 65 , and otherwise increments speeders.

SOLUTION:


if(speed < 0){
	reverseDrivers++;
}else if(speed < 1){
	parkedDrivers++;
}else if(speed < 40){
	slowDrivers++;
}else if(speed <= 65){
	safeDrivers++;
}else{
	speeders++;
}