Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/05/2011, 10:51
cachox_10
 
Fecha de Ingreso: mayo-2011
Mensajes: 1
Antigüedad: 13 años
Puntos: 0
Exclamación dudas en java

hola buenos dias quisiera hacer saber si alguien me puede ayudar sobre un error que me aparece cuando copilo que es :

principal.java: 34: cannot find symbol
symbol: variable n
location: class Principal

r*= n;

codigo del archivo es este


/**
* Write a description of class Principal here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Principal
{
public static void main(String args[])
{
int opc;

do
{
System.out.println("Multicalculadora");
System.out.println("1 Calcular Factorial");
System.out.println("2 Calcular Números Primos");
System.out.println("3 Calcular Sumatoria y Promedio");
System.out.println("4 Salir");

System.out.print("Ingrese la opción elegida: ");
opc = Consola.readInt();

switch(opc)
{
case 1: //Calcular Factorial
int j;
int r = 1;
System.out.println("Igrese un valor");
j = Consola.readInt();
for (int y = 1; y <= j; y++)
{
r *= n;
/* r = r * n */
System.out.println("Factorial de " + j + "= " + r);
}
break;

case 2: //Calcular Núme ros Primos
int num;
boolean nprimos;
System.out.println ("Ingrese el valor: ");
num = Consola.readInt ();
for (num =1; num<20; num++)
{
nprimos = true;
for (int z= 1; z < num /2; z+=1)
{
if (num%z==0)
{
nprimos = false;
}
}
}
break;


case 3: //Calcular Sumatoria y Promedio
int wCantidad, wRInicial, wRFinal;
System.out.print("Ingrese la cantidad de números a generar: ");
wCantidad = Consola.readInt();
System.out.print("Ingrese el límite inferior del intervalo ");
wRInicial = Consola.readInt();
System.out.print("Ingrese el límite superior del intervalo ");
wRFinal = Consola.readInt();

long wSumatoria = 0;
for(int i = 0; i < wCantidad; i++)
{
int wNum = (int)((Math.random() * (wRFinal - wRInicial)) + wRInicial);
wSumatoria += wNum;
}

System.out.println ("La sumatoria de los números aleatorios es: " + wSumatoria);
System.out.println ("El promedio de los números aleatorios es: " + ((double)wSumatoria/wCantidad));
break;

case 4: //Salida
System.out.println ("Gracias por Utilizar Multicalculadora");
break;

default:
System.out.println("Elija un opción del menú, no sea peregil");
}

} while(opc != 4);



}
}