Skip to content

Commit

Permalink
added simple converting (static variable)
Browse files Browse the repository at this point in the history
  • Loading branch information
m9henri committed Sep 28, 2024
1 parent b846732 commit 95e6e34
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ __pycache__/main.cpython-312.pyc
__pycache__/MainTracker.cpython-312.pyc
build
dist
start+tracker.spec
main.spec
ideas.txt
Empty file added calculator.log
Empty file.
35 changes: 30 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def transaction():

reason = input("Choose a reason on why you made the transaction (All in one line): ")

heavyness = input("How much did you spend/got? (no money symbol): ")
value = input("How much did you spend/got? (no money symbol): ")

print(f"Are these statements correct? (Y/n) {transaction_type}, {date}, {reason}, {heavyness}")
print(f"Are these statements correct? (Y/n) {transaction_type}, {date}, {reason}, {value}")

final_answer = input()
if final_answer == "Y":
print("\nCongrats, you've made a change!")
writing(transaction_type, date, reason, heavyness)
writing(transaction_type, date, reason, value)
time.sleep(5)
start()
if final_answer == "n":
Expand All @@ -26,24 +26,49 @@ def transaction():
transaction()
return

def writing(transaction_type, date, reason, heavyness):
def writing(transaction_type, date, reason, value):
file = open("tracker.log", "a")
file.write(f"Date: {date}\n")
file.write(f"Reason: {reason}\n")
file.write(f"How much spent/got: {transaction_type}{heavyness}\n\n")
file.write(f"How much spent/got: {transaction_type}{value}\n\n")
return

def converter():
os.system("cls")
print(
"""How do you wanna convert?
Select one of these two options:
- Convert dollars to euros (D)
- Convert euros to dollars (E)\n""")
entry_Q = input("Choose your operation: ")
value = int(input("How much of this currency do you wanna convert? "))
if entry_Q == "D":
final_value = value * 0.895404
print(f"Your outcome from ${value} is {final_value}€.")
if entry_Q == "E":
final_value = value * 1.116814
print(f"Your outcome from {value}€ is {final_value}$.")
back = input("\nDo you wish to continue? (Y,n) ")
if back == "Y":
converter()
if back == "n":
start()

def start():
os.system("cls")
print(
"""Welcome to the money tracker!
Select one of these three options:
- Add a new entry (A)
- Convert currency (C)
- Close the program (E)\n""")
entry_Q = input("Choose your operation: ")
if entry_Q == "A":
transaction()
if entry_Q == "C":
converter()
if entry_Q == "E":
os.abort()

Expand Down

0 comments on commit 95e6e34

Please sign in to comment.