Advertisement
Strade351

simpleCalc

Sep 8th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. /**
  2.  * Created by Anatoliy on 09.09.2016.
  3.  * DevelopHomework 1
  4.  * simpleCalc
  5.  */
  6.  
  7. import java.util.Scanner;
  8.  
  9. public class Calc {
  10.     public static void choseOp() {
  11.         Scanner in = new Scanner(System.in);
  12.  
  13.         double a = in.nextInt();
  14.         double b = in.nextInt();
  15.         String sop = in.next();
  16.  
  17.         if (sop.equals("+")) {
  18.             System.out.println(add(a, b));
  19.         }
  20.  
  21.         if (sop.equals("-")) {
  22.             System.out.println(substract(a, b));
  23.         }
  24.  
  25.         if (sop.equals("*")) {
  26.             System.out.println(multiply(a, b));
  27.         }
  28.  
  29.         if (sop.equals("+")) {
  30.             System.out.println(divide(a, b));
  31.         }
  32.     }
  33.  
  34.     static double add(double a, double b) {
  35.         double res = a + b;
  36.         return res;
  37.     }
  38.  
  39.     static double substract(double a, double b) {
  40.         double res = a - b;
  41.         return res;
  42.     }
  43.  
  44.     static double multiply(double a, double b) {
  45.         double res = a * b;
  46.         return res;
  47.     }
  48.  
  49.     static double divide(double a, double b) {
  50.         double res = a / b;
  51.         return res;
  52.     }
  53.  
  54.     public static void main(String[] args) {
  55.         choseOp();
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement