-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMathOperator.java
More file actions
52 lines (36 loc) · 1.22 KB
/
MathOperator.java
File metadata and controls
52 lines (36 loc) · 1.22 KB
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
45
46
47
48
49
50
51
52
package cursojava.executable;
import javax.swing.JOptionPane;
public class MathOperator {
public static void main(String[] args) {
double num, num2;
double result = 0.0;
boolean bNum = true;
String sNum;
String sNum2;
int result2;
do {
sNum = JOptionPane.showInputDialog("Informe o Valor para o Num: ");
sNum2 = JOptionPane.showInputDialog("Informe o Valor para o Num2: ");
num = Double.parseDouble(sNum);
num2 = Double.parseDouble(sNum2);
if(num > 0 && num2 > 0){
bNum = false;
}
}while(bNum);
/*Sum*/
result = num + num2;
System.out.println("The sum of values " + num + " and "+ num2 +" is: "+ result);
/*Negative Sum*/
result = num - num2;
System.out.println("The Negative Sum of values " + num + " and "+ num2 +" is: "+ result);
/*multiplication Sum*/
result = num * num2;
System.out.println("The multiplication Sum of values " + num + " and "+ num2 +" is: "+ result);
/*division Sum*/
result2 = (int) (num2 / num);
System.out.println("The division Sum of values " + num2 + " and "+ num +" is: "+ result2);
/*rest Sum*/
result = num2 % num;
System.out.println("The rest Sum of values " + num2 + " and "+ num +" is: "+ result);
}
}