public int caughtSpeeding(int speed, boolean isBirthday) {
int result;
if(speed<=65){
if(speed<=60&& isBirthday==true){
return result=0;
}
else {
return result=0;
}
}
else if(speed<=85){
if(speed<=61&& isBirthday==true){
return result=1;
}
else {
return result=1;
}
}
return result=2;
}
Expected Run
caughtSpeeding(60, false) → 0 0 OK
caughtSpeeding(65, false) → 1 0 X
caughtSpeeding(65, true) → 0 0 OK
caughtSpeeding(80, false) → 1 1 OK
caughtSpeeding(85, false) → 2 1 X
caughtSpeeding(85, true) → 1 1 OK
caughtSpeeding(70, false) → 1 1 OK
caughtSpeeding(75, false) → 1 1 OK
caughtSpeeding(75, true) → 1 1 OK
caughtSpeeding(40, false) → 0 0 OK
caughtSpeeding(40, true) → 0 0 OK
caughtSpeeding(90, false) → 2 2 OK
other tests
X
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE