I just wrote this and I can't find the reason it won't solve the division as expected. Can someone please explain what's going on in here?
Here's the code:
/*
3/2
*/
package paradoja;
public class Paradoja {
public static void main(String[] args) {
float dividendo, divisor, resto, cociente;
dividendo = 3;
divisor = 2;
resto = dividendo % divisor;
cociente = dividendo / divisor;
System.out.printf("--------DIVISION--------\n");
System.out.printf("El propósito es dividir 3 entre 2 y, a continuación, hacer la prueba.\n------------------------\n");
System.out.printf("Dividendo = %.2f\nDivisor = %.2f\nCociente = %.2f\nResto = %.2f\n", dividendo, divisor, cociente, resto);
System.out.printf("--------PRUEBA--------\n");
System.out.printf("%.2f * %.2f + %.2f = %.2f (¿?)\n----------------------\n", cociente, divisor, resto, cociente * divisor + resto);
}
}
It's just a 3/2 division and further test. It returns 4 instead of 3. Thank you for your time!