Hi I'm new to Java and I need a little help.The problem is from coding bat:
You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases.
public int caughtSpeeding(int speed, boolean isBirthday) {
Integer int2 = 0;
if (speed <= 60){
int2 = 0;
}
if (isBirthday = true){
if (speed >=61 && speed <= 85){
int2 = 1;
}
if (speed >= 86){
int2 = 2;
}
}
if (isBirthday = false){
if (speed >=61 && speed <=80){
int2 = 1;
}
if (speed >= 81){
int2 = 2;
}
}
return int2;
}
I'm getting caughtSpeeding(65, true) should be 0 when my code runs to = 1 and caughtSpeeding(85, false) should be 2 when my code runs to = 1 again.
Thanks