title: how can I make this calculator using only one method?
body: <p>I'm trying to make this calculator
  I can make it using 4 methods, one for addition one for subtraction and ..... but I want to make it a simple as possible.
  how can I perform the 4 main actions using one method and then call it in static main?</p>
  <pre><code>package com.company;
  
  import java.util.Scanner;
  
  public class Main {
      final static String first = &quot;first number: &quot;;
      final static String sec = &quot;second number: &quot;;
  
      public static void main(String[] args) {
          Scanner scanner = new Scanner(System.in);
          System.out.println(&quot;what do you want to use? (multiply (input *), divide (input /), subtract (input -), addition (input +)&quot;);
          String input = scanner.nextLine();
          double answer = calculation(input);                 ----------------------
          System.out.println(answer);
      }
      public static double calculation(double element){       ----------------------
          Scanner scanner = new Scanner(System.in);
          System.out.println(first);
          double firstInput = scanner.nextDouble();
          System.out.println(sec);
          double secInput = scanner.nextDouble();
          return firstInput element secInput;                 ----------------------
      }
  }
  </code></pre>
  <p>can I change the <code>element</code> to (<code>+ - * /</code>) ?
  (the ------------------ part is were I have a problem)</p>