java programing

profileThemaster10
assignment.5.pdf

1

COP2250 Assignment 5

Purpose of exercise:

To understand and implement the selection constructs:

(a) The if/else construct, (b) The switch,

As they pertain to the Java programming language. Assignment: Write a 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) Write a class called TrafficViolations that determines types of traffic violations. (b) Write a 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

  • COP2250 Assignment 5
  • Purpose of exercise:
  • To understand and implement the selection constructs:
  • (a) The if/else construct,
  • (b) The switch,