Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
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?

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.
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.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: