title: How to make Switch in voidfunction Java
body: <p>EDITED : ALREADY DONE THANKS GUYS</p>
  
  <p>Hello guys am just a newbie. I need to put this calculator with switch in a function. I need to convert it to void function (if that's what it is called). It already worked but the thing is it runs twice. I just putted addition to make my code short but I need it with other operations as well. If anyone know please post it. Here is my code:</p>
  
  <pre><code>import java.io.*;
  
  public class Cal {
  
    static char Switch() throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      System.out.println("\n\n");
      System.out.println("1]Addition");
      System.out.println("2]Subtraction");
      System.out.println("3]Multiplication");
      System.out.println("4]Division");
      System.out.print("\nEnter Your Choice : ");
      char r = br.readLine().charAt(0);
  
      switch (r) {
        case '1':
          Add1();
          Add2();
          break;
        default:
          System.out.print("Error");
          break;
  
      }
      return r;
    }
  
  
    static int Add1() throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
      System.out.println("\nAddition");
      System.out.print("enter 1st # : ");
      int x = Integer.parseInt(br.readLine());
      return x;
    }
  
    static int Add2() throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      System.out.print("enter 2nd # : ");
      int y = Integer.parseInt(br.readLine());
      return y;
  
    }
  
  
    public static void main(String[] args) throws IOException {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int y;
      int x;
      char r;
      r = Switch();
      x = Add1();
      y = Add2();
      System.out.print("\nSum " + (x + y));
  
  
    }
  }
  </code></pre>