Calculator Source Code in java




import java.util.Scanner;
public class Calculator
{
   public static void main(String[] args)
   {
       System.out.println("CALCULATOR");


       double n1=0;
       double n2=0;
       String operation;

       Scanner insert=new Scanner(System.in);

       System.out.println(" insert your operation");

       operation=insert.next();
       switch (operation)
       {
           case "+":
           {
               System.out.println("Enter your First Number..? ");
               n1=insert.nextDouble();
               System.out.println("Enter your Second Number..? ");
               n2=insert.nextDouble();
               System.out.println("The SUM is = "+(n1+n2));
               break;
           }
           case "-":
           {
               System.out.println("Enter your First Number..? ");
               n1=insert.nextDouble();
               System.out.println("Enter your Second Number..? ");
               n2=insert.nextDouble();
               System.out.println("The SUB is = "+(n1-n2));
               break;
           }
           case "/":
           {
               System.out.println("Enter your First Number..? ");
               n1=insert.nextDouble();
               System.out.println("Enter your Second Number..? ");
               n2=insert.nextDouble();
               System.out.println("The DIV is = "+(n1/n2));
               break;
           }
           case "*":
           {
               System.out.println("Enter your First Number..? ");
               n1=insert.nextDouble();
               System.out.println("Enter your Second Number..? ");
               n2=insert.nextDouble();
               System.out.println("The MUlT is = "+(n1*n2));
               break;

           }
       }


   }
}

Calculator Source Code in java Calculator Source Code in java Reviewed by Unknown on 12:40 Rating: 5
Tech Invension. Powered by Blogger.