
package divisionrestassucesivas;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class DivisionRestasSucesivas {

    public static void main(String[] args) {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        int dividendo = 0, divisor = 1, cociente, resto;
        
        try {           
              System.out.print("Introducir dividendo : ");
              dividendo = Integer.parseInt(bufferedReader.readLine());
              
              System.out.print("Introducir divisor : ");
              divisor = Integer.parseInt(bufferedReader.readLine());             
        } catch (Exception excepcion)
        { System.out.println(excepcion.getMessage());
        }   
 
        cociente = 0;
        while (dividendo >= divisor)
        {                                                                                   
            dividendo -= divisor;
            cociente++;
        }
        resto = dividendo;
        System.out.println("El cociente es : "+cociente+"    y el resto : "+resto);
    }
}
