hi guys i dint knew were to post this so if im worng plz move it i need a little help to a clase for this program but i got Illegal start of exprecion in line 37 plz help:frown: thx in advance public class ProgramaAcme { public static void main(String[] args) { long a = 0, b = 0, c = 0; for (long i = 0; i < 1; i++) Cubo(); while (i = m) {Esperar2Seg(); a = (long)Math.round(9999*Math.random()); b = (long)Math.round(9999*Math.random()); c = (long)Math.round(9999*Math.random()); } System.out.println("El numero menor entre ("+a+", "+b+", "+c+") es "+ min(a,b,c)); System.out.println(i +Cubo(m)); } static long min(long m, long n) { if (m < n) return m; else return n; } static long min(long n1, long n2, long n3) { return min( min(n1, n2), n3); } static void Esperar2Seg() { long ahora = System.currentTimeMillis(); long despues = ahora + 2500; long i = 0; while(System.currentTimeMillis() < despues) {i +=1; System.out.println(i+" Esto es un Loading para la respuesta"); } static long Cubo() { return m*m*m; } } }
you missed a } sign in static void esperar2seg, you do open it with a {, but then at the end you only close the while loop, so add another } behind the one in line 35, and you should be fine first rule when programming, watch your {, }, (, ) and most importantly, ; sings, those tend to give the most errors in my experience
i did that but dint work neither so i give up and start a new one but this one got a diferent problem at line 12 it said that cannot find symbol this is pissing me off since i have to finish this for tommorow so i really need help:frown: class Test { public static void main(String[] args) { long a = 0, b = 0, c = 0; for (long i = 0; i < 1; i++) {Esperar2Seg(); a = (long)Math.round(9999*Math.random()); b = (long)Math.round(9999*Math.random()); c = (long)Math.round(9999*Math.random()); long suma = a+=b+=c; } System.out.println("El numero menor entre ("+a+", "+b+", "+c+") es "+ min(a,b,c)); System.out.println("La suma de los tres numeros es"+ suma); } static long min(long m, long n) { if (m < n) return m; else return n; } static long min(long n1, long n2, long n3) { return min( min(n1, n2), n3); } static void Esperar2Seg() { long ahora = System.currentTimeMillis(); long despues = ahora + 2500; long i = 0; while(System.currentTimeMillis() < despues) {i +=1; System.out.println(" Se esta computando la Respuesta"); } } }
You've got a simple problem of trying to use suma outside of it's scope, it's declared inside the for loop therefore that's the only place it can be used. You just need to declare it before the for loop and it'll work. So it'd become: Code: class Test { public static void main(String[] args) { long a = 0, b = 0, c = 0; [b]long suma = 0;[/b] for (long i = 0; i < 1; i++) { Esperar2Seg(); a = (long)Math.round(9999*Math.random()); b = (long)Math.round(9999*Math.random()); c = (long)Math.round(9999*Math.random()); [b]suma = a+=b+=c;[/b] } System.out.println("El numero menor entre ("+a+", "+b+", "+c+") es "+ min(a,b,c)); System.out.println("La suma de los tres numeros es"+ suma); } Also please use the "code" tag in future to preserve indentation, code without indentation is a pain to read.
thatnks a lot it work me and sorry about the code thing it is that i ditn knew how it work sicne i were some time away from the forum anothere thing i also trying to get the minimun number of the random a,b and c elevated to the cube(^3) but i cant make that to work i also trying to sum the 3 numbers(random a, b and c) but it just give me the random a and dont do any sum what can i do?
suma = a + b + c; The way you were doing it made a also equal to a + b + c and b equal to b + c. The += operator adds two variables and assigns the result to the left hand one; the + operator just adds two variables.