Task
You have been asked by the toll company
to design an algorithm and write a program to record the data collected
by the sensors and cameras at the entries and exits to the toll roads.
Initially, you have to write a program to get the inputs through a
keyboard. The program should prompt the user to enter: a valid vehicle
number, travel date, travel time, entry point, exit point, toll charges
and GST. Each vehicle number is a six alphanumeric value such as ABC 123.
Then, the program should write the data into a file called
toll Charges.
You also have to design an algorithm and
use it to write a Python program that allows the user to read the
contents of the data file into a list. The program should then loop, to
allow a user to check various vehicle numbers against those stored in
the list. The loop should terminate when an "empty" input occurs - i.e.
when the user presses the [Enter] key on its own. (Obviously this last
entry should NOT be checked against the list!) If the vehicle number
entered by the user matches an element somewhere in the list, the
program should display the vehicle number together with the relevant
toll details stored in the file. If the entered vehicle number does not
match any element in the list, then the program should display the
vehicle number and a message saying that it IS NOT a valid vehicle
number.
Order Now
Order Now
Notes:
The records read from the data file
should be checked and NOT placed into the list if they are something
other than 6 characters. (Display a sensible message if the file is
found to have corrupt records in it.)
The vehicle numbers entered by the user
should be checked to ensure they are valid vehicle number and not
processed further if they are not. Your programs should use one or more
functions where sensible, and be documented fully. Use exceptions where
necessary.
Task 1 -
Draw Nassi Shneiderman (NS) diagram/s
that present the steps of the algorithm required to perform the task
specified. Include several NS diagrams for each function used in your
design.
Task 2 -
Select three sets of test data that will
demonstrate the 'normal' operation of your program; that is, test data
that will demonstrate what happens when a VALID input is entered. Select
two sets of test data that will demonstrate the 'abnormal' operation of
your program.
Set it out in a tabular form as follows:
test data type, test data, the reason it was selected, the output
expected due to using the test data, and finally the output actually
observed when the test data is used. It is important that the output
listings (i.e., screenshots) are not edited in any way.
Task 3 -
Implement your algorithm in Python. Comment on your code as necessary to explain it clearly.
In addition for this exercise, use
multiple functions, instead of using a single function to do everything.
Create a good design of the functions to make the best use of the code
and avoid duplicate calculations. For example, you can have a function
for calculating the weighted mark of an assignment and the function can
be used for calculating all weighted marks. Avoid duplicate code.
You also need to design your program so
that it has components that can be reused in another program, if needed.
Handle exceptions appropriately. Use appropriate data structure. Do
input validations on the file inputs to validate the vehicle number. Run
your program using the test data you have selected and complete the
test data table above.
Your submission will consist of:
1. Your algorithm through Nassi Shneiderman (NS) diagram/s.
2. The table recording your chosen test data and results
3. Source code for your Python implementation
It is important that the output listings are not edited in any way.
No comments:
Post a Comment