# Examples of algorithms inside algorithms in Java? Help is appreciated?

I know that my code below is an algorithm, but are there any algorithms inside the algorithm? If there aren't any algorithms inside the algorithm, how can I make it so that there are?
// Print the operation that user is using AND print the answer (2 numbers)
if (numberFirst == 2) {
if...
show more
I know that my code below is an algorithm, but are there any algorithms inside the algorithm? If there aren't any algorithms inside the algorithm, how can I make it so that there are?

// 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 (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) + ".");

}

Follow

2 answers
2

Are you sure you want to delete this answer?