Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions ez_budget.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
from ez_calculations import hcalc
from ez_calculations import fcalc
from ez_calculations import tcalc

deposit = float(input("Deposit: ")) # Deposit input prompt

housing = round(0.25 * deposit, 2)
food = round(0.1 * deposit, 2)
transportation = round(0.15 * deposit, 2)
print("Housing: " + str(round(deposit * hcalc, 2)))
print("Food: " + str(round(deposit * fcalc, 2)))
print("Transportation: " + str(round(deposit * tcalc, 2)))

# Version (1)
# deposit = float(input("Deposit: ")) # Deposit input prompt

# housing = float(input("Percentage for housing: "))
# food = float(input("Percentage for food: "))
# transportation = float(input("Percentage for transportation: "))

# hcalc = deposit * (housing / 100)
# fcalc = deposit * (food / 100)
# tcalc = deposit * (transportation / 100)

# hround = round(hcalc, 2)
# fround = round(fcalc, 2)
# tround = round(tcalc, 2)

# hresult = "Housing: " + str(hround)
# fresult = "Food: " + str(fround)
# tresult = "Transportation: " + str(tround)

# print(hresult)
# print(fresult)
# print(tresult)

# Version (2)
# deposit = float(input("Deposit: ")) # Entering Deposit amount

# housing = "{:.0%}".format(housing)
housingresult = "Housing: " + str(housing)
foodresult = "Food: " + str(food)
transportationresult = "Transportation: " + str(transportation)
# housing = float(input("Percentage of housing: ")) / 100.0
# food = float(input("Percentage of food: ")) / 100.0
# transportation = float(input("Percentage of transportation: ")) / 100.0

print(housingresult)
print(foodresult)
print(transportationresult)
# print("Housing: " + str(round(deposit * housing, 2)))
# print("Food: " + str(round(deposit * food, 2)))
# print("Transportation: " + str(round(deposit * transportation, 2)))
59 changes: 59 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.image import Image

class BudgetCalculatorApp(App):
def build(self):
self.layout = BoxLayout(orientation='vertical')
self.message = Label(text='Welcome to the Budget Calculator')
self.layout.add_widget(self.message)

# Adding the image to the welcome page
self.usmnt_image = Image(source='USMNT.png', size=(200, 200))
self.layout.add_widget(self.usmnt_image)

self.deposit_input = TextInput(hint_text='Enter your deposit', multiline=False)
self.housing_input = TextInput(hint_text='Percentage for housing')
self.food_input = TextInput(hint_text='Percentage for food')
self.transportation_input = TextInput(hint_text='Percentage for transportation')
self.calculate_button = Button(text='Calculate Budget')
self.calculate_button.bind(on_press=self.calculate_budget)
self.layout.add_widget(self.deposit_input)
self.layout.add_widget(self.housing_input)
self.layout.add_widget(self.food_input)
self.layout.add_widget(self.transportation_input)
self.layout.add_widget(self.calculate_button)

self.result_label = Label(text='')
self.layout.add_widget(self.result_label)

return self.layout

def calculate_budget(self, instance):
try:
deposit = float(self.deposit_input.text)
housing = float(self.housing_input.text)
food = float(self.food_input.text)
transportation = float(self.transportation_input.text)

hcalc = deposit * (housing / 100)
fcalc = deposit * (food / 100)
tcalc = deposit * (transportation / 100)

hround = round(hcalc, 2)
fround = round(fcalc, 2)
tround = round(tcalc, 2)

hresult = "Housing: $" + str(hround)
fresult = "Food: $" + str(fround)
tresult = "Transportation: $" + str(tround)

self.result_label.text = hresult + '\n' + fresult + '\n' + tresult
except ValueError:
self.result_label.text = 'Invalid input. Please enter valid numbers.'

if __name__ == '__main__':
BudgetCalculatorApp().run()