Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 13, 2019 08:12
Show Gist options
  • Save 0ryant/ddcbf9172c43a7e98170164c8d82df0d to your computer and use it in GitHub Desktop.
Save 0ryant/ddcbf9172c43a7e98170164c8d82df0d to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Classes; Simple Calculator
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