Advertisement
ryltar0

Untitled

Jul 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package arithmethique;
  7.  
  8. /**
  9.  *
  10.  * @author guill
  11.  */
  12. public class Calculator {
  13.     public static int add(int number1, int number2){
  14.         return number1+number2;
  15.     }
  16.    
  17.     public static int divInt(int number1, int number2){
  18.         if(number2 == 0){
  19.             throw new IllegalArgumentException("Cannot divide by 0!");
  20.         }
  21.         return number1/number2;
  22.     }
  23.    
  24.     public static double divReal(int number1, int number2){
  25.         if(number2 == 0){
  26.             throw new IllegalArgumentException("Cannot divide by 0!");
  27.         }
  28.         return (double)number1/number2;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement