You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int v
Posted: Wed Apr 27, 2022 3:43 pm
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 fine, 1 = small fine, 2 = big fine. If speed is 36 or less, the result is 0. If speed is between 37 and 70 inclusive, the result is 1. If speed is 71 or more, the result is 2. Unless it is your birthday -- on that day, your speed can be 5 higher in all cases. caughtSpeeding(35, false) — 0 caughtSpeeding(41, false) = 1 caughtSpeeding(41, true) - 0 For example: Test Result System.out.println(caughtSpeeding(58, false)); 1 Answer: (penalty regime: 0, 10, 20, 50, ... %) Reset answer 1 public int caughtSpeeding(int speed, boolean isBirthday) { 2 // TODO your code goes here 3)