-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simple Calculator
46 lines (36 loc) · 1.07 KB
/
Simple Calculator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//create a new class named Simple Calculator and then calling this in the main method.
//this file consists only of SimpleCalcualtor source file.
package com.company;
public class SimpleCalculator {
private double firstNumber;
private double secondNumber;
public void setFirstNumber(double firstNumber1) {
this.firstNumber = firstNumber1;
}
public void setSecondNumber(double secondNumber1) {
this.secondNumber = secondNumber1;
}
public double getFirstNumber() {
return firstNumber;
}
public double getSecondNumber() {
return secondNumber;
}
public double getAdditionResult() {
return ( firstNumber + secondNumber );
}
public double getSubtractionResult() {
return ( secondNumber - firstNumber );
}
public double getMultiplicationResult() {
return ( secondNumber * firstNumber );
}
public double getDivisonResult() {
if(secondNumber==0){
return 0;
}
else {
return (firstNumber / secondNumber);
}
}
}