Jan-14-2020, 10:20 PM
Hello i am a 13 year old novice programer trying to learn and just mess around with programing. I am making a bank program and have been trying to fix this one bug that just doesnt want to work. its problem is the fact that it just isn't doing the math right. Lets say i will deposit 9999.2 just for testing cause thats what i use to test. And then lets say i withdraw 9999.1 the answer will always come out as -0.1000000000000000000003638. i have been trying to fix this for a long time and need some help at this point. I have been programming this on my school computer using the website Repl.it this is the program i have worked on.
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 |
bal = float ( 0 ) while 1 = = 1 : float (bal) play_int = input ( "please enter wtd for withdraw and enter dep for deposit or enter bal to see your balance or enter end to end the program: " ) print ("") if play_int = = "dep" : while 1 = = 1 : try : dep = float ( input ( "please enter the amount you would like to deposit: " )) if dep < 0 : print ("") print ( "please enter a positive number" ) print ("") break print ("") bal = float (dep) + float (bal) print ( "you have deposited $" + str (dep)) print ("") str (bal) print ( "$" + str (bal)) print ("") float (bal) break except ValueError: print ("") print ( "you have entered a letter or a decimal please enter a whole number" ) print ("") elif play_int = = "wtd" : while 1 = = 1 : try : wtd = float ( input ( "please enter the amount you would like to withdraw : " )) if wtd < 0 : print ("") print ( "please enter a positive number" ) print ("") break print ("") bal = float (wtd) - float (bal) print ( "you have withdrawn " + str (wtd)) print ("") print ( str (bal)) print ("") float (bal) break except ValueError: print ("") print ( "you have entered a letter or a decimal please enter a whole number" ) print ("") elif play_int = = "bal" : str (bal) print ( "$" + str (bal)) float (bal) elif play_int = = "end" : print ( "ending program" ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "." ) print ( "program ended" ) break elif play_int = = "crash" : while 1 = = 1 : print ( "..................................................................................................................................................................." ) |
~~ UwU