-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson3arithmetiOperators.java
More file actions
66 lines (54 loc) · 1.34 KB
/
Lesson3arithmetiOperators.java
File metadata and controls
66 lines (54 loc) · 1.34 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Lesson3arithmetiOperators {
public static void main(String[]args){
/*
there arithmetic operators include
- addition +
-subtraction -
multiplication*
division /
modulus %
*/
double num1=10.0;
double num2= 3.0;
double output=0;
output=num1 + num2;
// output= num2 - num2;
// output = num1 / num2;
// output=num1 * num2;
// output=num1 % num2;
System.out.println(output);
//ARGUMENT ASSIGNMENT OPERATOR
/*
- addition +=
-subtraction -=
multiplication *=
division /=
modulus %=
*/
int x =100;
int y =20;
x+=y; //same as x= x + y;
// x-=y; //same as x= x - y;
// x*=y; //same as x= x * y;
// x/=y; //same as x= x / y;
// x%=y; //same sa x = x % y;
//
System.out.println(x);
//INCREMENT AND DECREMENT OPERATORS
int a=1;
a++;//icreament
// a--;//decrement
System.out.println(a);
//ORDER OF OPERATIONS [P-E-M-D-A-S]
/*
PARENTHESIS
EXPONENTS
MULTIPLICATION
DIVISION
ADDITION
SUBTRACTION
*/
double result = 3+4*2/2.0;
System.out.println("the result of the calculation is " +result);
}
}