-
Notifications
You must be signed in to change notification settings - Fork 0
/
metroCard.py
54 lines (42 loc) · 1.8 KB
/
metroCard.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
43
44
45
46
47
48
49
50
51
52
53
54
# ENTER YOUR VALUES HERE
# [ ] add feature so below variables can be assigned though user input
CURRENT_METROCARD_BALANCE = 15.4
FAIR = 4.20
REMAINING_BALANCE = 0.2
# below is the working code, do not change unless you know what you're doing
highBalance = False
runningBalance = CURRENT_METROCARD_BALANCE
runCount = 0
while not runningBalance % FAIR < REMAINING_BALANCE:
runCount += 1
runningBalance += 15
print(runningBalance)
if runningBalance > 9999999:
break
# if runningBalance > 500:
# print(
# "The balance required is over $500, which is not realistic, please increase the remaining balance allowed"
# )
# highBalance = True
# break
if highBalance != True:
print(
f"$ {str(runningBalance)} is the required balance as of now, this will give you {round(runningBalance / FAIR)} trips"
)
# metroCard.py
# This script calculates the number of trips that can be taken with a given balance on a metro card.
# Usage:
# - Set the values of CURRENT_METROCARD_BALANCE, FAIR, and REMAINING_BALANCE at the top of the script.
# - Run the script to see the number of trips that can be taken with the given balance.
# Variables:
# - CURRENT_METROCARD_BALANCE: The current balance on the metro card.
# - FAIR: The cost of a single trip.
# - REMAINING_BALANCE: The minimum remaining balance required on the card after a trip.
# Output:
# - If the balance required is over $500, the script will print an error message.
# - Otherwise, the script will print the required balance and the number of trips that can be taken with that balance.
# Example:
# - CURRENT_METROCARD_BALANCE = 15.4
# - FAIR = 4.20
# - REMAINING_BALANCE = 0.4
# - Output: "$ 60.4 is the required balance as of now, this will give you 14 trips"