My doubt is like doing a cycle or loop that adds up a quantity hasta que sea positiva
Example:
-870+360 = -510
-510+360= -150
-150+360 = 210
and only shows the positive result ie 210 in the example
My doubt is like doing a cycle or loop that adds up a quantity hasta que sea positiva
Example:
-870+360 = -510
-510+360= -150
-150+360 = 210
and only shows the positive result ie 210 in the example
You can do it using a while
and using the operator + =, resulting in 210
:
int valor = -870;
while(valor < 0){
valor+= 360;
}
System.out.println("valor resultante : " + valor);
having as output:
valor resultante : 210
x=valor_inicial;
for (i=valor_inicial;i<=0;i+=360){
x=i;
}