-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivide.java
More file actions
33 lines (30 loc) · 771 Bytes
/
Divide.java
File metadata and controls
33 lines (30 loc) · 771 Bytes
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
public class Divide {
public static void main(String[] args){
int dividend = -2147483648;
int divisor = -1;
int quotient = 0;
int track = 0;
if(isNeg(dividend)){
Math.abs(dividend);
track++;
}
if(isNeg(divisor)){
divisor *= -1;
track++;
}
System.out.println(Math.abs(-4));
System.out.println(dividend);
System.out.println(divisor);
while(dividend>=divisor){
dividend-= divisor;
quotient++;
}
for(int i =0; i < track; i++){
quotient*= -1;
}
System.out.print(quotient);
}
public static boolean isNeg(int a){
return a < 0;
}
}