# Are there any algorithms present in this program? Help is appreciated?

I don't know If there are any algorithms in my program below. If there are no algorithms in my program, how could I add algorithms to it?

// Print the operation that user is using AND print the answer (2 numbers)

if (numberFirst == 2) {

if (operation.equals("1"))

System.out.println("You are using addition." + " Your answer is " + (num1 + num2) + ".");

if (operation.equals("2"))

System.out.println("You are using subtraction." + " Your answer is " + (num1 - num2) + ".");

if (operation.equals("3"))

System.out.println("You are using multiplication." + " Your answer is " + (num1 * num2) + ".");

if (operation.equals("4"))

System.out.println("You are using division." + " Your answer is " + (num1 / num2) + ".");

if (operation.equals("5"))

System.out.println("You are using an exponent." + " Your answer is " + Math.pow(num1, num2) + ".");

}

// Print the operation that user is using AND print the answer (3 numbers)

if (numberFirst == 3) {

if (operation.equals("1"))

System.out.println("You are using addition." + " Your answer is " + (num1 + num2 + num3) + ".");

if (operation.equals("2"))

System.out.println("You are using subtraction." + " Your answer is " + (num1 - num2 - num3) + ".");

if (operation.equals("3"))

System.out.println("You are using multiplication." + " Your answer is " + (num1 * num2 * num3) + ".");

if (operation.equals("4"))

System.out.println("You are using division." + " Your answer is " + ((num1 / num2) / num3) + ".");

}

}

}

### 2 Answers

- mchl_the_citizenLv 41 year agoFavorite Answer
There are two basic algorithmic structures: iteration and recursion. Iteration is simply the repetition of processing steps. Recursion occurs when a method or function calling on itself. Your program is an example of the former rather than the latter.

- Login to reply the answers

- EddieJLv 71 year ago
Every program *IS* an algorithm -- a method used to accomplish something.

Algorithms use 4 basic control constructs: Sequence, selection, iteration, and function calls.

- ...Show all comments
- Average Anon1 year agoReport
@EddieJ

Okay, thanks for the help :) - Login to reply the answers