8 Replies  10840 Views  Last Post: 10 October 2007  02:08 PM
#1
fractions
Posted 06 October 2007  11:27 AM
I need in java language. Please help
I just need the function.
Replies To: fractions
#2
Re: fractions
Posted 06 October 2007  11:39 AM
#3
Re: fractions
Posted 06 October 2007  11:48 AM
PennyBoki, on 6 Oct, 2007  11:39 AM, said:
/* * Fraction.java * * Created on October 6, 2007, 8:39 AM * * To change this template, choose Tools  Template Manager * and open the template in the editor. */ /** * * @author Hakob */ import java.util.*; import java.io.*; public class Fraction { public Fraction() { } public static int gcd(int num, int Num) { if (num % Num == 0) { return Num; } else { return gcd(Num, num % Num); } } public static void main(String[] args)throws IOException { int Number; InputStreamReader reader = new InputStreamReader(System.in); BufferedReader input = new BufferedReader(reader); System.out.println("Enter your first number"); String choice = input.readLine(); int num = Integer.parseInt(choice); System.out.println(num); System.out.println("Enter your second number"); String number = input.readLine(); int Num = Integer.parseInt(number); System.out.println(Num); num = num + Num; System.out.println("Sum " +num); } }
This post has been edited by PennyBoki: 06 October 2007  02:32 PM
#5
Re: fractions
Posted 06 October 2007  12:49 PM
Programmist, on 6 Oct, 2007  12:18 PM, said:
the problem is when I am adding 1/2 +3/4 or 1.0 + 3.0 it can't read my input.
and i don't know why it can read my numbers.
#6
Re: fractions
Posted 06 October 2007  02:20 PM
jack85, on 6 Oct, 2007  12:49 PM, said:
Programmist, on 6 Oct, 2007  12:18 PM, said:
the problem is when I am adding 1/2 +3/4 or 1.0 + 3.0 it can't read my input.
and i don't know why it can read my numbers.
my results are one number (ex: 1) but not 1/2 or something similar.
I need that my answer be like with fraction (ex: 3/4)
please help
#7
Re: fractions
Posted 06 October 2007  07:52 PM
#8
Re: fractions
Posted 10 October 2007  11:59 AM
sl4ck3r, on 6 Oct, 2007  07:52 PM, said:
A man I am getting my answer with pointer( ex: 1.25). How can I change 1.25 in to 5/4 in java language. Can you help me with showing me a small function that I can use in my program.
Thanks
#9
Re: fractions
Posted 10 October 2007  02:08 PM
