Wednesday, November 19, 2014

Formatting a users answer




I am writing a simple learning program that does basic math. Everything is working as needed except for when it comes to division. I need to know if there is a way to format the users input to two decimal places and that when the program checks the users answer against the division, it gives it a yay or nay. Right now, it wants the answer out to 12 decimal places.




So for 5/3



I would like it to accept the answer 1.67




not 1.666666666667




Is there a way to do this?




If you need more information, please let me know, I can upload a code snipet if needed as well.




Thanks in advance!







No comments:

Post a Comment