forked from stjohn/csci127
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LIRRtransit.py
45 lines (34 loc) · 1.57 KB
/
LIRRtransit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#CSci 127 Teaching Staff
#March 2018
#A template for a program that computes LIRR transit fares.
#Modified by: ADD YOUR NAME HERE
def computeFare(zone, ticketType):
"""
Takes as two parameters: the zone and the ticket type.
Returns the LIRR Transit fare, as follows:
If the zone is 1 and the ticket type is "peak", the fare is 8.75.
If the zone is 1 and the ticket type is "off-peak", the fare is 6.25.
If the zone is 2 or 3 and the ticket type is "peak", the fare is 10.25.
If the zone is 2 or 3 and the ticket type is "off-peak", the fare is 7.50.
If the zone is 4 and the ticket type is "peak", the fare is 12.00.
If the zone is 4 and the ticket type is "off-peak", the fare is 8.75.
If the zone is 5, 6, or 7 and the ticket type is "peak", the fare is 13.50.
If the zone is 5, 6, or 7 and the ticket type is "off-peak", the fare is 9.75.
If the zone is greater than 8, return a negative number (since your calculator does not handle inputs that high).
"""
fare = 0
###################################
### FILL IN YOUR CODE HERE ###
### Other than your name above, ###
### this is the only section ###
### you change in this program. ###
###################################
return(fare)
def main():
z = int(input('Enter the number of zones: '))
t = input('Enter the ticket type (peak/off-peak): ').lower()
fare = computeFare(z,t)
print('The fare is', fare)
#Allow script to be run directly:
if __name__ == "__main__":
main()