Question: Python, in my question from before I had asked this https://www.chegg.com/homework-help/questions-and-answers/python-would-go-creating-money-class-stores-monetary-values-dollars-cents-instance-variabl-q23376373# and now have one other question. I want to create a program that opens

Python, in my question from before I had asked this https://www.chegg.com/homework-help/questions-and-answers/python-would-go-creating-money-class-stores-monetary-values-dollars-cents-instance-variabl-q23376373# and now have one other question. I want to create a program that opens this original package and do the following, 1 Display Money, 2 Add or subtract money, 3 Convert money to Yen 4 Convert money to Euro 5 Convert to Canadian Dollar 6 Exit. This is my code so far but I am confused on how to do 2-5. I will post my code down below, also the file name that I am importing and changing which contains the code given by kumarvinay is named Money. Thank you again I really do appreciate the help as I am sure that this probably seems like kind of a dumb thing to ask!!!

while True:

answer = input(' Hello user, please select one of the following, 1:Display Money, 2:Add or subtract money, 3:Convert money to Yen 4:Convert money to Euro 5:Convert to Canadian Dollar 6: Exit. ')

if answer == '1':

import Money

continue

elif answer == '2':

import Money in __add__.py

elif answer == '6': exit()

else: print('Sorry, you did not enter a vaild answer. The program will loop until a valid choice is given. ')

continue

here is the code I used from my other answer,

class Money:

def __init__(self, dollar, cents): self.dollar = dollar; self.cents = cents;

def __repr__(self): print("$" + str(self.dollar) + "." + str(self.cents))

def __add__(self, obj): self.dollar = self.dollar + obj.dollar self.cents = self.cents + obj.cents

def getEuro(self): value = self.dollar + self.cents/100 value = value * 0.84 return value

def getYen(self): value = self.dollar + self.cents/100 value = value * 110.25 return value

def getCanadianDollar(self): value = self.dollar + self.cents/100 value = value * 1.25 return value

m1 = Money(200,20) m2 = Money(300,45) m1.__repr__() m2.__repr__() m1.__add__(m2) m1.__repr__()

print("(In Euro)",m2.getEuro()) print("(In Yen)",m2.getYen()) print("(In Canadian Dollar)",m2.getCanadianDollar())

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!