|
these are ads that support the board lol internet: ytcracker tour is looking more like NEXT YEAR! TAG is having problems placing dates that make sense. sorry. |
|
|
#1 |
|
Join Date: Sep 2009
Posts: 32
|
I'm making a Fraction calculator and i've gotten to the point where i can solve it to it's final answer, the only problem i'm stumped on is how to simplify the final answer. plz help
|
|
|
|
|
#2 |
|
internet moneymaker wannabe.
|
lookup how modulo works, you'll need to find remainders here.
|
|
|
|
|
#3 |
|
Join Date: Jan 2008
Location: no love for bitches
Posts: 4,183
|
divide the fraction each number of the fraction by the denominator.. if the denominator yields a non integer # then its no good
Last edited by nox; 11-03-2009 at 08:34 PM. |
|
|
|
|
#4 |
|
Join Date: Jan 2009
Posts: 161
|
find the least common factors of the denominator and numerator and just cancel like terms... unless i'm missing the point do you have like Integer1/Integer2 ?
|
|
|
|
|
#5 |
|
We Gettin -بجدية Money!
|
uhmm
create a new class and you're gonna have to do it contructor style like how ure last thread was... and try this Code:
private void Reduce(){
int a = numerator;
int b = denominator;
int c = 0;
while( b!= 0 )
{
c = a % b;
a = b;
b = c;
}
denominator/=a;
numerator/=a;
}
i did this last week in my comp sci class.
__________________
Current PimpLeon Logo - Gmh - I Fucked Your Mother
- - ![]() |
|
|
|
|
#6 | |
|
Join Date: May 2005
Posts: 5,592
|
Quote:
Code:
package reduce;
public class Reduce
{
private int numerator;
private int denominator;
public static void main (String[] args)
{
Reduce(2, 4); // example call
}
public void Reduce(int numerator, int denominator)
{
int numerator = this.numerator;
int denominator = this.denominator;
int c = 0;
while( b != 0 )
{
c = numerator % denominator;
numerator = denominator;
denominator = c;
}
denominator/=a;
numerator/=a;
System.out.print(numerator + "\n" + denominator);
}
}
|
|
|
|
|
|
#7 |
|
We Gettin -بجدية Money!
|
lol mx. basically the same thing broe...
i had it so he'd have to create another class cause in hte OP he said he got everything down but the reducing... so when it was done evaluating what ever code he did have he'd just have to put Reduce(numerator,denominator); in his main class, without him havin to change up or move his code around
__________________
Current PimpLeon Logo - Gmh - I Fucked Your Mother
- - ![]() |
|
|
|
|
#8 |
|
Join Date: Nov 2009
Posts: 1
|
Great post! It's very nice and userful. Thank you so much for Paul post.
|
|
|