caughtSpeeding

From ggc

Jump to: navigation, search

http://www.javabat.com/prob?id=Logic.caughtSpeeding

if(isBirthday==true || speed<=40) { return 0; } if(speed>=61 && speed<=80) { return 1; } if(speed>=60 && speed<=81) { return 0; } else { return 2; }

This is the code I have so far, but i need more to finish. This solves all but two of the situations.




Solution

public int caughtSpeeding(int speed, boolean isBirthday) {


 if (isBirthday && speed <=65)
 {return 0;}
 if (isBirthday && speed >=66 && speed <=85) 
 {return 1;}
 
 if (isBirthday && speed >=86)
 {return 2;}
 
 if (speed <=60)
 {return 0;}
 if (speed >=61 && speed <= 80)
 {return 1;}
 if (speed >=81)
 {return 2;}


 else {return 2;}




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