Need someone that knows something in java scrip

Discussion in 'Programming/Html' started by CVND, Dec 1, 2005.

  1. CVND

    CVND Master Guru

    Messages:
    803
    Likes Received:
    0
    GPU:
    BFG 6800 GT OC Modded with NV5
    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;
    }
    }
    }
     
  2. DrFreeze

    DrFreeze Guest

    Messages:
    4,852
    Likes Received:
    1
    GPU:
    MSI GT740 2GB
    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
     
  3. CVND

    CVND Master Guru

    Messages:
    803
    Likes Received:
    0
    GPU:
    BFG 6800 GT OC Modded with NV5
    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");
    }
    }
    }
     
  4. Elleomea

    Elleomea Master Guru

    Messages:
    416
    Likes Received:
    0
    GPU:
    Radeon Mobility 9000 (M9)
    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.
     

  5. CVND

    CVND Master Guru

    Messages:
    803
    Likes Received:
    0
    GPU:
    BFG 6800 GT OC Modded with NV5
    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?
     
    Last edited: Dec 8, 2005
  6. Elleomea

    Elleomea Master Guru

    Messages:
    416
    Likes Received:
    0
    GPU:
    Radeon Mobility 9000 (M9)
    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.
     
    Last edited: Dec 8, 2005
  7. CVND

    CVND Master Guru

    Messages:
    803
    Likes Received:
    0
    GPU:
    BFG 6800 GT OC Modded with NV5
    thx a lot
    at last the program it is ready
    thx a lot
    i really thx you
     
  8. zietleben

    zietleben Master Guru

    Messages:
    585
    Likes Received:
    0
    GPU:
    6800gs

    learn ****ing english
     

Share This Page