Results 1 to 3 of 3
Thread: Need help on Fraction
- 07-05-2009, 09:11 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 1
- Rep Power
- 0
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 #2
Look at the / and % operators, especially when applied to int with an int result.
- 07-24-2009, 09:46 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
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 {
/**
* @author javamadd
*/
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");
}
}
Similar Threads
-
Rediculous problem?! Assigning a fraction to a double variable
By Tzoshirzup in forum New To JavaReplies: 3Last Post: 11-24-2008, 07:01 PM -
(Help) Fraction Summation and Exponents
By SapphireSpark in forum New To JavaReplies: 19Last Post: 10-09-2008, 04:01 AM -
Big Fraction 1.00
By JavaBean in forum Java SoftwareReplies: 1Last Post: 03-26-2008, 04:24 AM -
Trouble getting Julia fraction correct.
By yllawwally in forum New To JavaReplies: 0Last Post: 12-21-2007, 02:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks