-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuddy.py
193 lines (153 loc) · 4.26 KB
/
buddy.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env python3
#Buddy (CLI Version)
#Income/Expenses Program
import os
import sys
import time
import datetime
x = datetime.datetime.now()
os.system('clear')
print ()
print ("###########################################")
print ("# Calculates income and expenses on #")
print ("# a monthly basis. Prints results to #")
print ("# screen w/option to save as text file. #")
print ("# Whole numbers only, wont do decimals. #")
print ("###########################################")
print ()
time.sleep (0.5)
input("Press [Enter] to continue... ")
os.system('clear')
print ()
bold = '\033[1m'
end = '\033[0m'
red = '\033[91m'
green = '\033[92m'
yellow = '\033[93m'
print (f"{bold}MONTHLY INCOME AND EXPENSES\n{end}")
time.sleep (0.5)
name = input("Name: " )
print ()
time.sleep (0.5)
month = input("Month: " )
print ()
time.sleep (0.5)
#gather info
print ()
print (f"{bold}-ANSWERS MUST BE IN DOLLAR AMOUNTS-\n\n{end}")
time.sleep (0.5)
income = input("What is your monthly income? $" )
income = int(income)
print ()
time.sleep (0.5)
rent = input("How much is your rent? $" )
rent = int(rent)
print ()
cons = input("How much for consumers? $" )
cons = int(cons)
print ()
cable = input("How much for internet? $" )
cable = int(cable)
print ()
car = input("How much for car insurance? $" )
car = int(car)
print ()
food = input("How much for food/groceries? $" )
food = int(food)
print ()
gas = input("How much for gas? $" )
gas = int(gas)
print ()
person = input("Personal items, clothes, etc: $" )
person = int(person)
print ()
other = input("Other expenses? $" )
other = int(other)
print ()
cell = input("Cell phone bill? $" )
cell = int(cell)
print ()
#processing delay
import sys, time
string = 'Processing...\n'
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(.07)
#print to screen
os.system('clear')
print ()
print (f"{bold} --RESULTS-- \n{end}")
time.sleep (0.5)
print (name, " | ", month, (x.strftime("%Y")) + "\n")
print ('Monthly Income: $'f"{income}\n")
print (' Expenses 'f"\n")
print (' Rent: $'f"{rent}")
print (' Consumers: $'f"{cons}")
print (' Internet: $'f"{cable}")
print (' Car Ins: $'f"{car}")
print (' Food: $'f"{food}")
print (' Gas: $'f"{gas}")
print (' Personal: $'f"{person}")
print (' Other: $'f"{other}")
print (' Phone: $'f"{cell}\n")
time.sleep (1)
a = rent
b = cons
c = cable
d = car
e = food
f = gas
g = person
h = other
i = cell
total = (a + b + c + d + e + f + g + h + i)
print (f"{bold} Total Costs: ${total}\n{end}")
time.sleep (0.5)
remain = (income - total)
print (f"{bold} Remaining: ${remain}\n{end}")
time.sleep (0.5)
#two more questions
print ()
sav = input(" How much into savings account? $" )
sav = int(sav)
print ()
left = (remain - sav)
print (f"{bold} Whats Left: ${left}{end}")
time.sleep (0.5)
print ("\n")
earn = input(" Additional earned income? $" )
earn = int(earn)
print ()
newt = (remain - sav + earn)
print (f"{bold} New Total: ${newt}{end}")
#Save file as
print ("\n")
saveas = input('Save File as: ')
print ()
#save as text file (w=writeOver, a=append)
#save to: files/filename
saveFile = open(saveas, 'w')
#write to text file
saveFile.write(f" --RESULTS-- \n\n")
saveFile.write(f"{name} | {month}" + (x.strftime(" %Y")) + "\n\n")
saveFile.write('Monthly Income: $'f"{income}\n\n")
saveFile.write(' Expenses 'f"\n\n")
saveFile.write(' Rent: $'f"{rent}\n")
saveFile.write(' Consumers: $'f"{cons}\n")
saveFile.write(' Internet: $'f"{cable}\n")
saveFile.write(' Car Ins: $'f"{car}\n")
saveFile.write(' Food: $'f"{food}\n")
saveFile.write(' Gas: $'f"{gas}\n")
saveFile.write(' Personal: $'f"{person}\n")
saveFile.write(' Other: $'f"{other}\n")
saveFile.write(' Phone: $'f"{cell}\n\n")
saveFile.write(' Total Costs: $'f"{total}\n\n")
saveFile.write(' Remaining: $'f"{remain}\n\n\n\n")
#two questions
saveFile.write(' How much into savings account? $'f"{sav}\n\n")
saveFile.write(' Whats Left: $'f"{left}\n\n\n")
saveFile.write(' Additional earned income? $'f"{earn}\n\n")
saveFile.write(' New Total: $'f"{newt}\n\n")
saveFile.close()
print ()