testing program with switch case using junit
<p>I want to write test case for calculator program in junit. I am new to junit environment. I can write tests for other programs but kind of stuck with testing for switch() case.</p>

<p>I really want to know how to to do it.</p>

<p>thanks in advance</p>

<p>here is my program </p>

<pre><code> import java.util.Scanner;

 //This program performs basic math operations such as :- +,-,*,/
  public class Calculator 

  {      
 public static void main(String[] args) 

 {
     double number1, number2;
     String Mathoperation;
     Scanner scannerObject = new Scanner(System.in);

     System.out.println("Enter first number");
     number1 = scannerObject. nextDouble();

     System.out.println("Enter second number");
     number2 = scannerObject. nextDouble();

     Scanner UserInput = new Scanner(System.in);
     System.out.println("\nHere are your options:");
     System.out.println("\n1. Addition, 2. Subtraction, 3. Divison, 4. Multiplication");
     Mathoperation = UserInput.next();

     switch (Mathoperation)  
     {
       case "1":
       System.out.println("Your answer is " + (number1 + number2));
       break;

       case "2":
       System.out.println("Your answer is " + (number1 - number2));
       break;

       case "3":
       System.out.println("Your answer is " + (number1 / number2));
       break;

       case "4":
       System.out.println("Your asnwer is " + (number1 * number2));
       break;

       default:
       System.out.println("");      
     }   
 }  

}
</code></pre>