Question: Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket. The program will need
Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket. The program will need to enter the posted speed limit, actual speed the car was going, and whether or not the car was in a school zone and the date of the violation. Additionally, you will collect information about the driver (see output for specifics). The way speeding tickets are computed differs from city to city. For this assignment, we will use these rules, which need to be applied in this order: 1. All tickets will start with a minimum amount of $75. 2. An additional $6 is charged for every mph over the posted speed limit. 3. If you are traveling over 30mph over the posted speed limit, an additional $160 is charged. 4. If the speeding occurred in a school zone, the cost of the ticket is doubled. You will then print the ticket on the output screen. This program is not concerned with checking for proper input. For example, if the posted speed limit is 55mph, and you were traveling 50mph, then a ticket would not be necessary in the first place. For this program, you can assume that the data will be entered correctly.
TICKET JAVA SHELL: public class Ticket { //Driver Information private String name, TDL, address, city, state, zip; //Violation Information private int postedSpeed, travelling, ticketAmount, day, month, year; private boolean schoolZone; public Ticket() { } public Ticket(String nm, String tdl, String addr, String cty, String st, String zp, int pSpd, int travel, int d, int m, int yr, String school) { } public void calcTicket() { } public String lastName() { return ""; } public String toString() { return""; } }
TICKET RUNNER JAVA SHELL: //Lab - import java.util.Scanner; import java.lang.System.*; public class TicketRunner { public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); System.out.println("The Speeding Ticket Program"); System.out.println(); System.out.println("By: John Smith"); // Substitute your own name here. System.out.println(" ============================== "); // add code for input here // Instantiate and print System.out.println(); } }
OUTPUT: Output #1 ----jGRASP exec: java Lab07Av100 The Speeding Ticket Program By: John Smith ============================== Name of Driver? --> Johnny Viking Drivers License Number? --> 02453756 Address? --> 234 Dulles City? --> Sugar Land State? --> TX Zip? --> 77044 Did the violation occur in a school zone? {Y/N} --> N Date of Violation: Month (number)? --> 02 Day? --> 14 Year? --> 21 What is the posted speed limit? --> 40 How fast was the car travelling in mph? --> 55 02/14/21 Johnny Viking (TDL: 02453756) 234 Dulles Sugar Land, TX 77044 Dear Citizen Viking, You have received this citation for driving 55 mph in an area with a posted speed limit of 40. This violation did not occur in a school zone. Your fine is $165.00 and can be paid at the address below. Please remember to buckle up and drive safely. ----jGRASP: operation complete.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
