Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Fraction program(with Class)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dark Mist




PostPosted: 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
Sponsor
sponsor
skatelhs




PostPosted: 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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: