# Need help on Fraction

• 07-05-2009, 09:11 PM
mitch25
Need help on Fraction
hi, I'm new to java and I need some idea on how can I do this program.

For example:
numerator: 7
denominator: 49
fraction type: proper fraction //the class will identify whether the fraction is proper, improper or mixed fractions
decimal equiv: 0.14286

Can anyone help me?

Thanks!
• 07-06-2009, 03:47 AM
Steve11235
Look at the / and % operators, especially when applied to int with an int result.
• 07-24-2009, 09:46 PM
Well ..jus see this
i wud say the solution is as simple as that ... but ..i m not sure abt the input .. how wud u input the numbers ?? jus numerator and denominator? then this shud work fine

import java.util.*;
public class fractions {

/**
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num,deno;
Scanner scanboy = new Scanner(System.in);
System.out.println("Enter num");
num = scanboy.nextInt();
System.out.println("Enter deno");
deno = scanboy.nextInt();
System.out.println("the fraction is " + num +"/" +deno++);
if ( num > deno)
System.out.println("Its an Improper fraction");
else
System.out.println("Its a Proper Fraction");
}

}