-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiv.java
25 lines (24 loc) · 826 Bytes
/
Div.java
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
package DailyCoding;
public class Div
{
public static void main(String[] args)
{
Div test = new Div();
System.out.println(test.divide(10,2));
}
private int divident; private int divisor;
public int divide(int divident, int divisor)
{
if (divisor > divident) return 0; //if divisor greater than divident, then quotient is 0 and remainder==divident
else//ortherwise substract divisor from divident untill divident is less than divisor
{
int quotient = 0;
while(divisor <= divident)
{
quotient ++;
divident = divident-divisor; //deduct the quantity of divisor from divident
}
return quotient;
}
}
}