Computer Science Canada

Fraction program(with Class)

Author:  Dark Mist [ 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?

Author:  skatelhs [ Fri May 30, 2003 1:16 pm ]
Post 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

Author:  Tony [ Fri May 30, 2003 3:09 pm ]
Post 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.


: