Created
August 13, 2019 08:12
-
-
Save 0ryant/ddcbf9172c43a7e98170164c8d82df0d to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Classes; Simple Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimpleCalculator { | |
private double firstNumber; | |
private double secondNumber; | |
public double getFirstNumber(){ | |
return firstNumber; | |
} | |
public double getSecondNumber(){ | |
return secondNumber; | |
} | |
public void setFirstNumber(double firstNumber){ | |
this.firstNumber=firstNumber; | |
} | |
public void setSecondNumber(double secondNumber){ | |
this.secondNumber=secondNumber; | |
} | |
public double getAdditionResult(){ | |
return (firstNumber+secondNumber); | |
} | |
public double getSubtractionResult(){ | |
return (firstNumber-secondNumber); | |
} | |
public double getMultiplicationResult(){ | |
return (firstNumber*secondNumber); | |
} | |
public double getDivisionResult(){ | |
if (secondNumber==0){ | |
return 0; | |
} else { | |
return (firstNumber/secondNumber); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment