Advertisement
vencinachev

Untitled

Sep 19th, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class App {
  4.     public static void main(String[] args) {
  5.    
  6.        
  7.         Scanner scan = new Scanner(System.in);  
  8.         System.out.println("Enter opperation:");
  9.         String opperation = scan.next();
  10.            
  11.         System.out.println("Enter first number:");
  12.         double numberOne = scan.nextDouble();
  13.        
  14.         System.out.println("Enter second number:");
  15.         double numberTwo = scan.nextDouble();
  16.        
  17.         double sum = 0;
  18.    
  19.    
  20.         switch(opperation) {
  21.           case "-":
  22.               sum = numberOne - numberTwo;  
  23.               break;
  24.           case "+":
  25.               sum = numberOne + numberTwo;  
  26.               break;
  27.           case "/":
  28.               sum = numberOne / numberTwo;  
  29.               break;
  30.           case "*":
  31.               sum = numberOne * numberTwo;  
  32.               break;         
  33.         }
  34.        
  35.        
  36.         System.out.println("result:");
  37.         System.out.println(sum);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement