title: Java: Failed test with Calculator sumTwoNumbers, subtractTwoNumbers, divideTwoNumbers and multiplyTwoNumbers
body: <p>Task description:
  In a template below you have a simple calculator that subtracts, sums, divides, and multiplies the two numbers inside the switch statement. Now, we've decided to upgrade it to perform more complex tasks, such as logarithmic functions. For that, separate methods are a better solution. Let's start with decomposing what we have.</p>
  <p>Take a look at the template and decompose operations of the calculator into four methods: subtractTwoNumbers(long a, long b) for subtraction, sumTwoNumbers(long a, long b) for adding, divideTwoNumbers(long a, long b) for division and multiplyTwoNumbers(long a, long b) for multiplication. Each method should print the result of calculations.</p>
  <h2>Note that you can't divide by zero. In case your second argument is zero, you should print the &quot;Division by 0!&quot; message.</h2>
  <p>I am trying to create a calculator and get the following errors:</p>
  <p>FEEDBACK
  Failed test #1 of 6. Wrong answer</p>
  <p>This is a sample test from the problem statement!</p>
  <p>Test input:
  1 + 2
  Correct output:
  3</p>
  <p>Your code output:</p>
  <pre><code>import java.util.Scanner;
  
  class Main {
  
      public static void main(String[] args) {
  
          Scanner scanner = new Scanner(System.in);
          long num1 = scanner.nextLong();
          String operator = scanner.next();
          long num2 = scanner.nextLong();
  
  
          long result = 0;
          switch (operator) {
              case &quot;-&quot;:
                  result = subtractTwoNumbers(num1, num2);
                  break;
              case &quot;+&quot;:
                  result = sumTwoNumbers(num1, num2);
                  break;
              case &quot;/&quot;:
                  if (num2 == 0) {
                      System.out.println(&quot;Division by 0!&quot;);
                  } else {
                      result = divideTwoNumbers(num1, num2);
                      break;
                  }
              case &quot;*&quot;:
                  result = multiplyTwoNumbers(num1, num2);
                  break;
              default:
                  break;
          }
          System.out.println(result);
      }
  
      // Implement your methods here
      // Each method should print the result of calculations.
      //Note that you can't divide by zero.
      // In case your second argument is zero, you should print the &quot;Division by 0!&quot; message.
      public static long subtractTwoNumbers (long a, long b) { return a - b; }
      public static long sumTwoNumbers (long a, long b) {
          return a + b;
      }
      public static long divideTwoNumbers (long a, long b) {
          return a / b;
      }
      public static long multiplyTwoNumbers (long a, long b) {
          return a * b;
      }
  }
  </code></pre>
  <p>Can you please tell me what I did wrong there?
  Thanks &amp; BR
  <a href="https://i.stack.imgur.com/h5DY1.png" rel="nofollow noreferrer">enter image description here</a></p>