I need help with something in my Java class.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SheSheChan
    FFR Player
    • Sep 2003
    • 66

    #1

    I need help with something in my Java class.

    I noticed the Programming forum was taken down so I'm hoping I'm posting this in the right area.



    My mind just went blank, and I would love anyone who could help me out with any part of this. I know what I'm supposed to do but I can't think of what part of the equation would go in the rectangle/rhombus. Or even the equation itself. I can't think of how to get that pattern going. I'm pretty sure the checkmark by it means there's help on the textbook website but I can't find it. =x Thanks anyone~
    there's too much blood in my caffeine system
  • Squeek
    let it snow~
    • Jan 2004
    • 14444

    #2
    Re: I need help with something in my Java class.

    The algorithm is easy. It is addition, after all.

    int n = 10;
    double x = 1; //Accounts for the initial "1+" step.
    while (n > 0) {
    x += 1/(n^2);
    n--; }

    I uninstalled Java on this computer when I quit Computer Science years ago so I can't test this, but it should work.

    As for flowcharts, I was never one for explanatory coding. I coded to code. I quit Computer Science because everyone wanted rules and guidelines for how we should code. Also because Assembly Language sucked. Nobody should have rules placed on their coding technique. It's just stupid.

    So, I can't help with the flowchart.
    Last edited by Squeek; 10-12-2007, 01:14 AM.

    Comment

    • Hudelf
      FFR Veteran
      • Aug 2007
      • 93

      #3
      Re: I need help with something in my Java class.

      Originally posted by Squeek
      As for flowcharts, I was never one for explanatory coding. I coded to code. I quit Computer Science because everyone wanted rules and guidelines for how we should code. Also because Assembly Language sucked. Nobody should have rules placed on their coding technique. It's just stupid.
      Wow, my teachers seem to be a helluva lot better than yours were. My teachers have specifically told us that guidelines in coding are too restrictive, and will thus just tell us general conventions to follow, and good coding technique (How to avoid creating hard-to-debug errors, good commenting, etc). They also obviously teach us syntax and such, but never explicit rules to follow.

      Also, with regards to your code segment, that should work. Obviously it's missing the class declaration, but that should be a given anyways.

      Comment

      • SheSheChan
        FFR Player
        • Sep 2003
        • 66

        #4
        Re: I need help with something in my Java class.

        Originally posted by Squeek
        The algorithm is easy. It is addition, after all.

        int n = 10;
        double x = 1; //Accounts for the initial "1+" step.
        while (n > 0) {
        x += 1/(n^2);
        n--; }
        That's basically what my code looked like, with a few changes here and there. I'm preeeetty sure I got it right though. Thanks for your input though, I got to double check things. =)


        What I actually got for psuedocode (we didn't actually have to write the code, we just started with things) was:

        input: n

        sum <- 0

        i <- 1

        repeat the following three steps while i < or = to n:

        sq = i * i
        sum <- sum + 1/sq
        i = i + 1

        output = sum

        The point of doing this was more or less to make it general and usable with any variable.
        Last edited by SheSheChan; 10-12-2007, 08:06 PM.
        there's too much blood in my caffeine system

        Comment

        • lord_carbo
          FFR Player
          • Dec 2004
          • 6222

          #5
          Re: I need help with something in my Java class.

          Let's not let this thread become obsolete.

          ITT the Riemann Hypothesis.

          Anyone know some complex analysis?
          last.fm

          Comment

          • GuidoHunter
            is against custom titles
            • Oct 2003
            • 7371

            #6
            Re: I need help with something in my Java class.

            Originally posted by lord_carbo
            Anyone know some complex analysis?
            A little, yes.

            At the very least, I have an entire book on it.

            --Guido


            Originally posted by Grandiagod
            Originally posted by Grandiagod
            She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
            Sentences I thought I never would have to type.

            Comment

            Working...