title: Building a calculator in java (with a switch)
body: <p>I am using a switch to calculate two numbers, but when i try to do any sort of operator i just keep getting <code>0</code>.</p>
  
  <pre><code>//imports
  import java.util.Scanner;
  public class Calculator {
        public static void main (String[] args) {
  //get first number
          Scanner scan = new Scanner(System.in);
          System.out.println("Please enter the first number: &gt; ");
          int num1 = scan.nextInt();
  // get second number
          System.out.println("Please enter the second number: &gt; ");
          int num2 = scan.nextInt();
  // what the user wants to do
          System.out.println("Please enter the method you would like to use "
                  + "(+ , - , * , / , ^ ) &gt; " );
          String method = scan.next();
          char operation = method.charAt(0);
          String output = "";
  //switch for first number
          switch(num1) {
                  case 0: output+= "zero";
                          break;
                  case 1: output+= " one";
                          break;
                  case 2: output+= " two";
                          break;
                  case 3: output+= " three";
                          break;
                  case 4: output+= " four";
                          break;
                  case 5: output+= " five";
                          break;
                  case 6: output+= " six";
                          break;
                  case 7: output+= " seven";
                          break;
                  case 8: output+= " eight";
                          break;
                  case 9: output+= " nine";
                          break;
                  case 10: output+= " ten";
                          break;
  }
  // operation the user wants to use
        switch (operation){
            case '+' : output += " plus";
                       break;
            case '-' : output += " minus";
                       break;
            case '*' : output += " times";
                       break;
            case '/' : output += " divided by";
                       break;
            case '^' : output += " to the power of";
                       break;
  }
  //switch for second number
         switch (num2) {
                 case 0: output += " zero";
                         break;
                 case 1: output += " one";
                         break;
                 case 2: output += " two";
                         break;
                 case 3: output += " three";
                         break;
                 case 4: output += " four";
                         break;
                 case 5: output += " five";
                         break;
                 case 6: output += " six";
                         break;
                 case 7: output += " seven";
                         break;
                 case 8: output += " eight";
                         break;
                 case 9: output += " nine";
                         break;
                 case 10: output += " ten";
                         break;
  // calculate the answer
          }
            int answer = 0 ;
         switch (answer) {
             case '+' : answer = (answer + (num1 + num2));
                 break;
             case '-' : answer = (answer + (num1 - num2));
                 break;
             case '*' : answer = (answer + (num1 * num2));
                 break;
             case '/' : answer = (answer + (num1 / num2));
                 break;
             case '^' : answer = (answer + (int) (Math.pow(num1,num2) ));
                 break;
         }
         System.out.println(output + " equals " + answer );
      }
  }
  </code></pre>
  
  <p>Im pretty sure that my problem is at the bottom of the program with the actual function </p>
  
  <pre><code> int answer = 0 ;
         switch (answer) {
  </code></pre>
  
  <p>Starting somewhere around that area, just having a hard time figuring it out. Maybe somebody else can give input as to what i am doing wrong</p>
  
  <p>Thanks in advance for any help</p>