speedingTicket
Category: Programming
Author: Jessica Miller
Book Chapter: 4.2
Problem: speedingTicket
Write a static method speedingTicket that decides whether a given driver should be given a speeding ticket from a police officer. The method accepts three parameters: the driver's car speed in miles per hour, as an integer; the current speed limit, as an integer; and whether or not the police officer has eaten a donut today, as a true/false value. (A police officer that has eaten a donut is happy, so he/she is less likely to give the driver a ticket.) Your method should return true if the driver should receive a speeding ticket, and false if not. A driver should be given a speeding ticket if any of the following conditions are met: The officer has eaten a donut (true) and the driver's speed is at least 10 mph over the speeding limit. The officer has not eaten a donut (false) and the driver's speed is at least 5 mph over or under the limit. The driver is going 100 mph or faster, regardless of the speed limit or donut status. You may assume that the integers passed as parameters will be non-negative.