java - Can't see why this won't work | Loop won't run -
public static void main(string[] args) { scanner xis = new scanner(system.in); int h1 = 0; int m1 = 0; int h2 = 0; int m2 = 0; int[] numeros = new int[4]; system.out.println("type numbers."); for(int = 0; <= numeros.length; i++) { numeros[i] = xis.nextint(); h1 = h1 + numeros[0]; m1 = m1 + numeros[1]; h2 = h2 + numeros[2]; m2 = m2 + numeros[3]; } system.out.println(h1); system.out.println(h2); int horaduracao = (h2 - h1) * -1; int minutoduracao = (m2 - m1) * -1; if(horaduracao <= 0) { horaduracao = horaduracao + 24; } if (minutoduracao <= 0) { minutoduracao = minutoduracao + 59; horaduracao = horaduracao + -1; } }
when user types answer this: system.out.println("type numbers.");
it won't continue next part of code.
sorry if it's repost, kept searching time this, couldn't find.
your loop goes 5 iterations, not 4. should remove = terminating clause in order working. for(int = 0; < numeros.length; i++)
Comments
Post a Comment