done with python You have been asked to work on a much larger project for a mobi
ID: 3836587 • Letter: D
Question
done with python
You have been asked to work on a much larger project for a mobile app that helps people manage their budget. Your portion of the code requires you to create a class that will take into it the amount of money someone has earned for a month and their monthly expenses. The class will then determine if there is any money left over. If there is money left over (balance > 0) the class will display to the user the message "Good job you saved money this month". If the monely left over is zero, then the class will display to the user the message "You neither saved or overspent". Finally if the balance is less than 0 or negative, the class needs to display the message "You did not do too well this month". Your class needs to have 2 methods. One to calculate the balance and the other to determine the message. Additionally you will need code in main() that will create an object and run the methods. Once you have completed your code, attach your Python file here.
needs to be done with python
Explanation / Answer
class Budjet(object):
"""A class that makes various tasty fruits."""
def __init__(self, monthlyEarned, monthlyExpences):
self.monthlyEarned = monthlyEarned
self.monthlyExpences = monthlyExpences
self.result = 0
def description(self):
if self.result > 0:
print ("Good job you saved money this month")
elif self.result == 0:
print ("You neither saved or overspent")
else:
print ("You did not do too well this month")
def balance(self):
self.result = self.monthlyEarned - self.monthlyExpences
self.description()
def main(monthlyEarned,monthlyExpences):
budjet = Budjet(monthlyEarned,monthlyExpences)
budjet.balance()
main(123,213)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.