Calculate and notify violators of the fines

Assignment Help JAVA Programming
Reference no: EM131565553

Java program that can be used to calculate and notify violators of the fines and/consequences for road traffic breaches as shown in the schedule below.

The violation notice may comprise of any of the following:

- One or more of non-moving violations alone.
- Combination of non-moving violations, and one kind of moving violation for excess speeding, or speeding in construction zone, but not both.
- Combination of non-moving violations, and one kind of moving violation for speeding in school zone, or speeding in toll facility, but not both.

Non-Moving Violation
- No driver's license $25.00
- Expired tag $20.00
- No registration $20.00
- No insurance $10.00

Moving Violation
-Speeding violation or speeding in construction zone Miles over the Speed Limit o 1 - 5 MPH Warning o 6 - 9 MPH $130.00 o 10 - 14 MPH $205.00 o 15 - 19 MPH $405.00 o 20 - 29 MPH $455.00 o 30 MPH or over $605.00 and court appearance
-Speeding in school zone or speeding within a toll facility o 1 - 5 MPH $155.00 o 6 - 9 MPH $255.00 o 10 - 14 MPH $305.00 o 15 - 19 MPH $405.00 o 20 - 29 MPH $455.00
2

-One kind of moving violation only, for excess speeding, or speeding in construction zone, but not both.
-One kind of moving violation for speeding in school zone, or speeding in toll facility, but not both.

In formulating your solution: (a) class called TrafficViolations that determines types of traffic violations. (b) test class called TestTrafficViolations that implements the class TrafficViolations (c) Demonstrate knowledge of the if statement and the switch statement by using the if/else statement to determine the miles, and the switch statement for the other criteria. (d) You determine a suitable format for the output

This is what I have so far...

import java.util.*;
import java.lang.*;
import java.io.*;
class TrafficViolations
{
public static void trafficviolation()
{
int speed;
int lic;
int registration;
int insurance;
double fine =0;
double sfine=0;
int location;

Scanner scan = new Scanner(System.in);
System.out.println(" Do you have license (1/0) 1 for yes or 0 No ( for No driver license $25.00)");
lic=scan.nextInt();
System.out.println(" Tag expired (1/0) 1 for yes or 0 No ( for Expired tag $20.00)");
int tag=scan.nextInt();
System.out.println(" Do you have No Registration (1/0) 1 for yes or 0 No ( No registration $20.00)");
registration=scan.nextInt();
System.out.println(" Do you have Insurance(1/0) 1 for yes or 0 No (No insurance $10.00)");
insurance=scan.nextInt();
//Moving Violation
//Speeding violation or speeding in construction zone
System.out.println(" Enter Speed ");
speed =scan.nextInt();
System.out.println(" Enter location (Enter 1/0) if school area 1 otherwise zero ");
location= scan.nextInt();
if(lic==0)
{
fine=fine+25;
}
if(insurance==0)
{
fine=fine+10;
}
if(registration==0)
{
fine=fine+20;
}
//Miles 0ver the Speed Limit
if (speed>1 &&speed <=5 )
{
System.out.println("Warning: Miles Over the Speed Limit please drive below the speed limit");
}
if (speed>6 &&speed <=9 )
{
sfine=sfine+130.00;
}
if(speed>10 && speed <=14 )
{
sfine=sfine+205.00;
}
if(speed>=15 && speed<=19 )
{
sfine=sfine+405.00;
}
if (speed>20 && speed<=29 )
{
sfine=sfine+455.00;
}
if (speed>30 )
{
sfine=sfine+605.00;
System.out.println(" Court appearance needed if speed is more than 30");
}
//Speeding in school zone or speeding within a toll facility
if (speed>1 &&speed <=5 && location ==1)
{
sfine=sfine+155.00;
System.out.println("Warning: Miles Over the Speed Limit please please drive below the speed limit");
}
if (speed>6 && speed <=9 && location ==1 )
{
sfine=sfine+255.00;
}
if (speed>10 && speed <=14 && location ==1 )
{
sfine=sfine+305.00;
}
if (speed>15 && speed <=19 && location ==1)
{
sfine=sfine+405.00;
}
if (speed>20 && speed <=29 && location ==1)
{
sfine=sfine+455.00;
}
System.out.println("Fine for Non Moving ViolationFine"+fine);
System.out.println("Fine for Moving ViolationFine"+sfine);
System.out.println("Fine for Non Moving+Moving ViolationFine"+(fine+sfine));
}
}

Reference no: EM131565553

Questions Cloud

Concept of object oriented programming : What is the significance of the concept of inheritance within the concept of object oriented programming?
Elaborate on ways that social media platforms can proactive : Suggest and elaborate on three ways that social media platforms can be more proactive and thorough with their review of the types of content that appear on thei
Create java application that implements use of an int array : Create a Java application that implements use of an int array. Use for loops to iterate through the array using the array's length variable to stay
What is the current economic situation for ucco : What is the current economic situation for UCCO? What suggestions can Barbara make to help mitigate financial issues?
Calculate and notify violators of the fines : Java program that can be used to calculate and notify violators of the fines and/consequences for road traffic breaches
Specify the variation nature of the project in question : Select one project from the working or educational environment of your choice and specify the variation nature of the project in question.
Find the displacement as a function of t : An object at the end of a spring is immersed in liquid. Its velocity (in cm/s) is then described by the equation v = 2e-2x + 3e-5t, where t is the time (in s).
Find the velocity v of a falling brick in terms of the time : When we consider the resisting force of the air, the velocity v (in ft/s ) of a falling brick in terms of the time (in s) is given by dv/(32 - 0.5v) = dt.
Simple java programming tests : The java coding that accepts a distance it kilometers, sends it to a method which converts it to miles, and then displays the result

Reviews

Write a Review

JAVA Programming Questions & Answers

  Prepare executable programs a translate program and a

prepare executable programs. a translate program and a dictionary program. the programs will be written in any

  Specify, design and implement a class

Specify, design and implement a class that can be used to hold information about a musical note. Test it with an appropriate driver program.

  Write a java program that has a method named atomic

Demonstrate in the program how two threads can, sometimes, invoke atomic() concurrently.

  Q1write a program called linearstringsearchjava that looks

q1.write a program called linearstringsearch.java that looks for a target string value in an array of string values.

  Programming languages for example pascal

Some programming languages for example Pascal have used the semi colon to seperate statements while java uses it to terminate the statements. which of them in your opinion is most natural and least likely to result in syntax errors? support your a..

  Implementation of the finger protocol

Server programs are rarely implemented as non-threaded applications, even though that is how you implemented your previous server application.

  Modify the java application using netbeans ide

Modify the Week Three Java application using NetBeans IDE to meet these additional and changed business requirements The application will now compare the total annual compensation of at least two salespersons.

  Re matches a string shorter

A. _____ No RE matches a string shorter than itself. B. _____ Any RE without closure (* or +) describes only finitely many strings. C. _____ No problem in NP can be solved in polynomial time. D. _____

  Considered to be an improved version

Part (c) is considered to be an improved version of Part (b). You may use an array (2-dimessional) to store some values that has been computed during the run so that when making recursive calls the program does not compute certain values over and ..

  Assignment related to java programming

Question 1: Write a java program to compute the squares of the numbers in the array list like 1, 2, 3, 4... up to 50. Question 2: Write a java program to compute the sum of numbers and average in the array list up to 50.

  Assignment on java applets and activex controls

Go online and search for information about security threats posed by Java applets and ActiveX controls. Note that most of these programs are small in size and downloaded onto computers over the Internet.

  Write the string copy and string concatenation functions

Write the string copy and string concatenation functions and first version should use array subscripting, and the second version should use pointer arithmetic.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd