Professional Documents
Culture Documents
}
while(opc!='e');
}
/////////////////////////////////MENU///////////////////////////////////////////
static char menu()throws IOException
{char opc;
do{System.out.println("Menu");
System.out.println("a.-Leer N:");
System.out.println("b.-Calcular el factorial :");
System.out.println("c.-Invertir el n�mero : ");
System.out.println("d.-Suma de sus d�gitos");
System.out.println("e.-Terminar ");
System.out.println("Seleccione una opci�n del [a-e] : ");
opc=br.readLine().toLowerCase().charAt(0);
}
while (opc<'a'||opc>'e');
return opc;
}
///////////////////////LEER N//////////////////////////////////////////////////
static int LeerN(String Mensaje)throws IOException
{int N;
do{System.out.print(Mensaje);
N=Integer.parseInt(br.readLine());
}
while(N<=0);
return N;
}
//////////////////////Factorial////////////////////////////////////////////////
static int Factorial(int N)throws IOException
{int i, fac=1;
for(i=1;i<=N;i++)
{fac=fac*i;
}
return fac;
}
///////////////////////Invertir el n�mero//////////////////////////////////////
static int Invertido(int N)throws IOException
{int Ninv=0, res;
while(N>0)
{res=N%10;
Ninv=Ninv*10+res;
N=N/10;
}
return Ninv;
}
/////////////////////Suma de digitos//////////////////////////////////////////
static int suma(int N)throws IOException
{int res, sd=0;
while(N>0)
{res=N%10;
sd=sd+res;
N=N/10;
}
return sd;
}
//////////////////////Reportar/////////////////////////////////////////////////
static void Reportar (String Mensaje, int X)throws IOException
{System.out.println("\n"+Mensaje+" = "+X);
return;
}
/////////////////////Mensaje//////////////////////////////////////////////////
static void Mensaje()throws IOException
{System.out.println("\nNo ha ingresado datos....");
return;
}
////////////////Terminar/////////////////////////////////////////////////////
static void Terminar()throws IOException
{System.out.println("\nGracias por usar el programa!");
return;
}