
Concept explainers
Using Java code:
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.

The Algorithm of the code:-
1. Prompt the user to enter the speed limit.
2. Store the speed limit in a variable called "speedLimit".
3. Prompt the user to enter their driving speed.
4. Store the driving speed in a variable called "drivingSpeed".
5. Calculate the speed difference between the speed limit and the driving speed by subtracting the speed limit from the driving speed.
6. Store the speed difference in a variable called "speedDifference".
7. If the speed difference is less than or equal to -10, then print "You were driving too slowly. You have received a $50 ticket."
8. Else if the speed difference is greater than or equal to 6 and less than or equal to 20, then print "You were speeding. You have received a $75 ticket."
9. Else if the speed difference is greater than or equal to 21 and less than or equal to 40, then print "You were driving dangerously. You have received a $150 ticket."
10. Else if the speed difference is greater than 40, then print "You were driving extremely dangerously. You have received a $300 ticket."
11. Otherwise, print "You were within the speed limit. No ticket issued."
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 3 images

I used the code above to create a
java7 error: cannot find symbol
int speedLimit = input.nextInt();
symbol: variable input
java9 error: cannot find symbol
int drivingSpeed = input.nextInt();
symbol: variable input
2 errors
I used the code above to create a
java7 error: cannot find symbol
int speedLimit = input.nextInt();
symbol: variable input
java9 error: cannot find symbol
int drivingSpeed = input.nextInt();
symbol: variable input
2 errors
- With your current Java knowledge, you have decided to write a program that will calculate a student's GPA for the current semester. The program should prompt the user to enter four values representing the number of A, B, C and Ds earned for the semester then calculate and display the GPA. When writing the program, consider the following: • The program should prompt the user to enter four INTEGER values representing the number of grades earned for each letter grade. • GPA is calculated by dividing the total points earned by the total number of credits attempted. • All of the courses taken for the semester are 4 credits. • To determine the calculations, A grades have a point value of 4, B grades a point value of 3, C grades a point value of 2 and D grades a point value of 1. • Total Number of Credits Attempted = Sum of Number of Courses multiplied by the number of credits for each course. • The total points earned is the sum of the credit hours multiplied by the point value for each…arrow_forwardDesign a Java program to take user information about t dollar bills. You will do calculations and print the result as below. Note that user can enter any number and your output user's input. Example: Enter nunber of one dollar bills: 769 769 dollar bills will be change to Hundred Fifty Twenty Ten Five Onearrow_forwardI want solution with stepsarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





