5.12 LAB: Speeding ticket Write a program that is given two integers representing a speed limit and driving speed in miles per hour (mph) and outputs the traffic ticket amount. Driving 10 mph under the speed limit (or slower) receives a $50 ticket. Driving 6 - 20 mph over the speed limit receives a $75 ticket. Driving 21 - 40 mph over the speed limit receives a $150 ticket. Driving faster than 40 mph over the speed limit receives a $300 ticket. Otherwise, no ticket is received. Ex: If the input is: 35 45 the output is: 75 Ex: If the input is: 35 26 the output is: 0
Added by Noelia W.
Close
Step 1
```java public class SpeedingTicket { public static void main(String[] args) { // Code will go here } } ``` Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 78 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Aarya B.
Write a program that is given two integers representing a speed limit and driving speed in miles per hour (mph) and outputs the traffic ticket amount. Driving 10 mph under the speed limit (or slower) receives a $50 ticket. Driving 6 - 20 mph over the speed limit receives a $75 ticket. Driving 21 - 40 mph over the speed limit receives a $150 ticket. Driving faster than 40 mph over the speed limit receives a $300 ticket. Otherwise, no ticket is received. Ex: If the input is: 35 45 the output is: 75 Ex: If the input is: 35 26 the output is: 0
Supreeta N.
Write a program with four methods for calculating the cost of a yearly auto service visit. The methods will be titled yearlyService. - yearlyService(no parameters) - Will return the standard service charge. - yearlyService(one parameter) - Will return the standard service charge with an added oil change fee. - yearlyService(two parameters) - Will return the standard service charge with an added oil change fee and a tire rotation charge. - yearlyService(three parameters) - Will return the standard service charge with an added oil change fee, a tire rotation charge, along with a coupon amount that will be deducted from the total cost. Write a main method that will test each of these methods two times.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD