Associate Program Material

Associate Program Material

Appendix G

Sequential and Selection Process Control Structure

In the following example, the third line of the table specifies that the fine on a speeding
ticket that is 11 MPH over the speed limit is $75.00 plus 150% of the MPH over the speed limit,
the court cost is 40% of the fine, and the total fine is the sum of the fine and the court cost.
Therefore, the fine on a speeding ticket that is 11 MPH over the speed limit is $75 + (11 * 1.5) =
$91.50, the court cost is 91.50 * .4 = $36.60, and the total fine is $128.10.
MPH Over Speed
Limit
Fine
Court Cost Total Fine
0 – 4 MPH
$25 + 100% of MPH over speed limit
20% of fine Fine + Court Cost
5 – 9 MPH
$50 + 125% of MPH over speed limit
30% of fine Fine + Court Cost
10 – 14 MPH
$75 + 150% of MPH over speed limit
40% of fine Fine + Court Cost
15 – 19 MPH
$100 + 175% of MPH over speed
50% of fine Fine + Court Cost
limit
20+ MPH
$150 + 200% of MPH over speed
75% of fine Fine + Court Cost
limit

Use these test values for the design walkthrough.

Test Values

Input(overlimit)
3 MPH
7 MPH
12 MPH
18 MPH
25 MPH

Fine

25 + (3 * 1) =28
50 + (7 *1.25) = 58.75
75 + (12 * 1.5) = 93
100 + (18 * 1.75) = 131.50
150 + (25 * 2) = 200

Court cost
28 * .2 = 5.60
58.75 * .3 = 17.63
93 * .4 = 37.20
131.50 * .5 = 65.75
200 * .75 = 150

Total

28 + 5.60 = $33.60
58.75 + 17.63 = $76.38
93 + 37.20 = $130.20
131.5 + 65.75 = $197.25
200 + 150 = $350.00

You must use the Selection Control structure to determine the calculation for the different
MPH over the speed limit ranges.

Analysis:
1. Receive input (OverLimit) from user
2. Calculate Fine
3. Calculate CourtCost
4. Display TotalFine

Input

OverLimit (integer: >0)

Output

TotalFine (float >0.00)

Input
Name: OverLimit
Type: Integer
Range: >0

Name: Fine
Type: float

Processes
1.InputData

2.CalculateCost

Output
Name: Fine
Type: Integer
Range: >0

Name: TotalFine
Type: float

Appendix G
IT/210 Version 5

2

MainModule
Declare OverLimit as integer
Declare Fine as float
Declare TotalFine as float

Call InputData
Call CalculateCost
Call DisplayTotal
End MainModule

InputData
Write, “Enter MPH over the speed limit”

Input OverLimit
End InputData

CalculateCost
IF OverLimit = < 4
THEN Fine = 25 + OverLimit / 100
CourtCost = Fine * 20 / 100
ELSE IF OverLimit = 5 < 9
THEN Fine = 50 + OverLimit / 125
CourtCost = Fine * 30 / 100
ELSE IF OverLimit = 10 < 14
THEN Fine = 75 + OverLimit / 150
CourtCost = Fine * .4
ELSE IF OverLimit = 15 < 19
THEN Fine = 100 + OverLimit / 175
CourtCost = Fine * .5
ELSE IF OverLimit = > 20
THEN Fine = 150 + OverLimit / 200
CourtCost = Fine * .75
End IF
TotalFine = Fine + CourtCost
End InputData

DisplayTotal
Display “The total fine after court cost is $”TotalFine

Appendix G
IT/210 Version 5

3

End DisplayTotal

Leave a Reply