how to make a calculator using switch case in java

Solutions on MaxInterview for how to make a calculator using switch case in java by the best coders in the world

showing results for - "how to make a calculator using switch case in java"
Edoardo
15 Jul 2016
1/* Create Switch cases */
2Scanner sc= new Scanner(System.in);
3int firstNum= sc.nextInt();
4int secondNum= sc.nextInt();
5System.out.println("Enter an operator (+, -, *, /):");
6char operator= sc.next().chartAt(0);
7double result=0;
8switch(operator){
9  case "+":
10    result+= firstNum+ secondNum;
11    break;
12  case "-":
13    result+= firstNum-secondNum;
14    break;
15  case "*":
16    result+= firstNum*secondNum;
17    break;
18  case "/":
19    result+= firstNum/secondNum;
20    break;
21}
queries leading to this page
calculator using switch case in javaswitch case java use for calculatorjava calculator using switch casedesign a simple calculator using switch components using 2 text fields inputdesign a simple calculator using switch components using 2 text fieldssimple calculator in java using switch casejava calculator switch casecalculator avec switch in javawrite a program to create calculator in java must contain mfollowing method input vales 2cadd 2csub 2cdivide 2cmultiply and having two clases and method overloadingcreate a simple calculator application which asks a user to enter two numbers and the operation 28e g 2b 2c 2c x 2c etc 29 that they e2 80 99d like to perform on the numbersmake a calculator using switch statement in javajava calculator program using switch casecalculator using switch case and do while in javacalculator in java using switchjava program to make a simple calculator using switch casecase switch java calculatorwe have to create a calculator and take input from the user that which operation perform like addition subtraction multiplication by choosing an operation should be performed using scanner method javaswitch case calculator in javawe have to create a calculator and take input from the user that which operation perform like addition subtraction multiplication by choosing an operation should be perform using scanccer method javamake calculator using switch case in javacalculator program using switch case in javacalculator in java using switch case in loopwrite a program to create calculator in java must contain 5 methods and two java classes calculator java program using switchjava switch statement add subtract dividecalculator program in javacreate a calculator using switch case in javajava program to display basic calculator using switch statement we have to create a calculator and take input from the user that which operation perform like addition subtraction multiplication by choosing an operation should be perform using switch statement in javajava program to make calculatorjava operator how to make an calculatormake a simple calculator using stringcreate a calculator class that has following methods 3a sum 2c multiply 2c divide 2c modulus 2c sin 2c cos 2c tan the user should be able to call these methods without creating an object of calculator class program in java java calculatordesign a simple calculator using switch componentsjava calc with switchswitch case in java calculatorcalculator in java using switch casecalculator java switch caseimplement calculator application with add 2c divide 2c multiply and subtract methods java switch case calculatorhow to make a calculator using switch case in javasimple calculator program in java using switch casescientific calculator in java using switch casecode for calculator in javawrite a program to create calculator in java must contain mfollowing method input vales 2cadd 2csub 2cdivide 2cmultiply and having to clases to implement these methodjava simple calculatorusing switch case how to create calculatorin javacalculator with add subtract methods javacalculator with switch case in javacalculator program in java using switch casejava program for calculator using switch casejava calculator switch case loophow to make a calculator using switch case in java