Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Method called is not performing correctly

import java.util.Scanner;
public class testSequence {

    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
        System.out.println("Enter a number: ");
      int enterNumber = scan.nextInt();
      System.out.println("1 for Iteration, 2 for Recursion: ");
      int type = scan.nextInt();

      if (type == 1){
          computeIteration(enterNumber);
      } else if (type == 2){
          computeRecursion(enterNumber);
      }
    }


    public static int computeIteration(int enterNumber) {
        int answer;
        int multiplier = 1;
        int count = 0;
        int addend = 0;
        if (enterNumber == 0) {
            count++;
            return enterNumber;
        } else if (enterNumber == 1) {
            count++;
            return enterNumber;
        } else {

            for (int i = 0; i <= enterNumber; i++) {//need to adjust "i" for counter correction

                enterNumber = (multiplier * 2) + addend;
                addend = multiplier;
                multiplier = enterNumber;
                count += 1;
            }//end for loop
            answer = enterNumber;
        }//end else
        return answer;
    }//end computeIteration

    public static int computeRecursion(int n) {
        int count = 0;
        if (n == 0) {
            count++;
            return 0;
        } else if (n == 1) {
            count++;
            return 1;
        } else {
            count++;
            return computeRecursion(2 * (n - 1)) + computeRecursion(n - 2);
        }

    }//end computerRecursion()

}//end Sequence()
share|improve this question

put on hold as off-topic by Tunaki, mdfst13, Vogel612, forsvarir, Phrancis 2 days ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it." – Tunaki, mdfst13, Vogel612, forsvarir, Phrancis
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Welcome to Code Review! This question is off-topic because the code that you have provided is not working. Please consider asking on Stack Overflow (though you should read their SO Question Checklist first). Read more about what is on-topic for Code Review – Joe C 2 days ago
    
The code does compile and run, it just isn't doing what I thought it should do. – platypus87 2 days ago
    
...which means it is not working, and is therefore off-topic for this site. – Joe C 2 days ago
    
Mm, okay then. My apologies. I will check out stack overflow as you suggested. – platypus87 2 days ago