Fraction program(with Class)
Author 
Message 
Dark Mist

Posted: Fri May 30, 2003 12:57 pm Post subject: Fraction program(with Class) 


i am doing a fraction program(class), where the user enters two fractinons and decide what operation to use. but the ouput has to be in a mixed fraction. like 1 1/2...
how do i do that and where do i put i? 





Sponsor Sponsor



skatelhs

Posted: Fri May 30, 2003 1:16 pm Post subject: (No subject) 


couldnt you do something with 2 variables?
or maybe something with splitting them, like using 1..2 (the first two characters) and storing them somewhere and then using 3..4 to store the last two? then display them seperately with a / ? i dont really know, but hey, i tried.
adam 





Tony

Posted: Fri May 30, 2003 3:09 pm Post subject: (No subject) 


well first to make things easier you convert it to a common denominator... just multiple them both by each other... since you get computer to do it for you, doesnt matter if numbers are big. Do w/e operation you need then use mod to see if there're are any whole numbers in the result.
simplifing is also easy... just keep on dividing the numbers from 1/2 the number to 2 (well if result is an integer then divide). At the end of loop you should have the simpliest fraction. 
Tony's programming blog. DWITE  a programming contest. 





