Friday, 22 July 2011

Divide two numbers without slash

public class Division {

    public static void main(String[] args) {
        int number1 = 10;
        int number2 = 3;
        int count = 0;
        while(number1 > number2) {
          number1 = number1 - number2;
          count++;
        }
        System.out.println(count);
    }
}

No comments:

Post a Comment