Results 1 to 2 of 2
  1. #1
    dianar17 is offline Member
    Join Date
    Apr 2009
    Rep Power

    Default Count on cantor help!?

    I need some help coming up with the correct coding for the count on cantor problem. You can read an explanation of the problem in here:
    Java Code:
    The only difference is that I have to read the number from a file (already did it) and it does work that way, BUT I also have to calculate the sum of all terms before that number.

    3 is 2/1 - Sum: 2 1/2
    14 is 2/4 - Sum: 22 3/4

    I'm using a class named Racional, which I call from this problem to set the numerator and denominator of my number, and after that I call the sum method (also in my racional class). I can't seem to find the problem, but when I run the program it shows an error regarding my sum method. I did a somewhat similar code and the sum does work but not in the right way.

    Here's my racional class
    Java Code:
    And my code
    Java Code:
    I put a link to the files since they are quite long.
    I would really appreciate it if someone could help me!

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Hong Kong
    Rep Power


    Java Code:
    for (int t = 0; t < n.length; t++) {
       // code
    have you found any Strange in the for loop
    what if the text file only contain 3 numbers, how many times do the looping should do? is 3, not n.length

Similar Threads

  1. to get count value as a variable
    By arunkumarinfo in forum JDBC
    Replies: 2
    Last Post: 03-30-2009, 01:32 AM
  2. post count
    By codeflip in forum Forum Lobby
    Replies: 2
    Last Post: 03-12-2009, 02:20 AM
  3. Getting row count
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-11-2008, 08:49 AM
  4. how to count 2 inserts together?
    By kim85 in forum New To Java
    Replies: 0
    Last Post: 01-20-2008, 11:25 AM
  5. Getting row count from executeQuery()
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-05-2007, 02:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts