why is this code not working?

From ggc

Jump to: navigation, search

(caughtSpeeding)Im not sure what else to put in to make this code work.


This was my attempt:

public int caughtSpeeding(int speed, boolean isBirthday) {

if (speed >= 81)
{return 2;}
else if (speed >= 61 && speed <= 80)
{return 1;}
else
{ return 0;}
}

Answer

In general, if you don't use a parameter in the JavaBat problem, you probably do not fully take into account all of the information you need to take into account. For example, the code above works the same way regardless of whether it is your birthday or not. Doesn't the problem description say that things should happen differently depending upon whether it is your birthday or not?





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter