Numero primo
// Ingresar un número y determinar si es primo o no - Cisco Bautista
import [Link];
public class Ejercicio2
public static void main(String[] args)
int cont, i;
[Link]("\n\n\n Bienvenidos a este programa \n");
[Link](" Ingrese un número: ");
int num = new Scanner([Link]).nextInt();
cont = 0;
for(i = 1; i <= num; i++)
{
if((num % i) == 0)
cont++;
if(cont <= 2)
[Link]("\n El numero es primo");
else
{
[Link]("\n El numero no es primo");
Este código sirve para identificar el si apruebas o no dependiendo de una calificación mediante las sentencias
if y un menú por medio de do while
import [Link];
public class Promedio {
public static void main(String[] args) {
Scanner read = new Scanner ([Link]);
read = new Scanner ([Link]);
Scanner a1= new Scanner ([Link]);
int OPC;
double a;
do{
[Link]("Bienvenido");
[Link]("1 Iniciar");
[Link]("[Link]");
OPC = [Link]();
switch (OPC){
case 1:
[Link]("Promedio");
[Link]("Inserte un numero");
a = [Link]();
if (a<=5.9)
{
[Link]("Reprobado ");
}
if (a>=6 && a<=6.9)
[Link]("Suficiente");
if (a>=7 && a<=7.9)
[Link]("Regular");
if (a>=8 && a<=8.9)
[Link]("Bien");
if (a>=9 && a<=9.9)
[Link]("Muy bien ");
if (a>=10)
[Link]("Excelente");
}while(OPC<2);
Les comparto un programa que dada una frase cuenta las letras hasta encontrar un punto realizado en Java.
import [Link].*;
public class Contar
public static char obtenerCaracter(String fra, int i)
char carAux;
carAux = [Link](i);
return carAux;
}
public static void main(String args[])
{
// Declaraciones
// Definicion de objetos para entrada de datos por el teclado
InputStreamReader entrada = new InputStreamReader([Link]);
BufferedReader flujoEntrada = new BufferedReader(entrada);
// Variable para tomar los datos leidos del flujo de entrada
String datoEntrada;
// Variables
String frase="", frase2="", car2="";
int l,c;
char car;
[Link]("***********DADA UNA FRASE, CUENTA LAS LETRAS HASTA
ENCONTAR UN PUNTO****************");
[Link](" UTILIZA CADA VOCAL\n");
// Leer dato
try
[Link]("Teclee frase: ");
datoEntrada = [Link]();
frase = datoEntrada;
catch (IOException error)
[Link]("Error " + [Link]());
c= 0;
for (l=0;l<=[Link]()-1;l++)
car = obtenerCaracter(frase,l);
if (car != '.' ){
c = c + 1;
else{
[Link]("\n ");
[Link]("LA CANTIDAD DE LETRAS SON: ");
[Link]( + c);
}
}
// Imprimir salida
Está es una versión mejorada del primer programa en Java denominado MenuCena.
En este caso seria la segunda versión nombrada como MenuCena2 ó versión 2.0
Se han añadido nuevas variedades y los precios han sido modificados.
El programa esta hecho todo en Java.
package MenuCena;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class MenuCena extends JFrame implements ItemListener, ActionListener
String platos[] =
{ //-- Platos del Menú (6) --
"Entrantes" , //Primer plato.
"Carnes" , //Segundo plato.
"Pescados" , //Tercer plato.
"Postres" , //Postres.
"Bebidas" , //Bebidas.
"Café / Copa" //Café o Copa.
};
String variedades[][] =
{ //-- Entrantes (4) --
"Entremeses variados" , //1º- Entrante
"Marisco" , //2º- Entrante
"Ensalada" , //3º- Entrante
"Gazpacho" //4º- Entrante
},
{ //-- Carnes (7) --
"Filete de Ternera" , //1º- Carne
//"Chuletón de ternera", //2º- Carne
"Entrecot de ternera" , //3º- Carne
"Pato a la naranja" , //4º- Carne
"Filete de cerdo" , //5º- Carne
"OsoBuco" , //6º- Carne
"Filete de pollo a la plancha" //7º- Carne
},
{ //-- Pescados (3) --
"Merluza en salsa" , //1º- Pescado
"Bacalao al pil-pil", //2º- Pescado
"Besugo al horno" //3º- Pescado
},
{ //-- Postres (4) --
"Tarta al whiski" , //1º- Postre
"Flan" , //2º- Postre
"Helado" , //3º- Postre
"Postre de la casa" //4º- Postre
},
{ //-- Bebidas (6) --
"Vino blanco (botella)" , //1º- Bebida
"Vino tinto (botella)" , //2º- Bebida
"Agua pequeña (0,5 l.)" , //3º- Bebida
"Agua grande (1,5 l.)" , //4º- Bebida
"Cerveza (33 cl.)" , //5º- Bebida
"Refrescos (33 cl.)" //6º- Bebida
},
{ //-- Café / Copa (5) --
"Café sólo" , //1º- Café / Copa
"Café cortado" , //2º- Café / Copa
"Café con leche" , //3º- Café / Copa
"Licor de pacharán" , //4º- Café / Copa
"Copa de whisky" //5º- Café / Copa
}
};
String precio[][] =
{ //-- Precios de Entrantes (4) --
"10" , //1º- Precio de Entrante (Entremeses variados).
"10,50" , //2º- Precio de Entrante (Marisco).
"6,30" , //3º- Precio de Entrante (Ensalada).
"4,50" //4º- Precio de Entrante (Gazpacho).
},
{ //-- Precios de Carnes (7) --
"5" , //1º- Precio de Carne (Filete de Ternera).
"7,90" , //2º- Precio de Carne (Chuletón de ternera).
"8,50" , //3º- Precio de Carne (Entrecot de ternera).
"5,50" , //4º- Precio de Carne (Pato a la naranja).
"3,50" , //5º- Precio de Carne (Filete de cerdo).
"4,50" , //6º- Precio de Carne (OsoBuco).
"3,50" //7º- Precio de Carne (Filete de pollo a la
plancha).
},
{ //-- Precios de Pescados (3) --
"6,90" , //1º- Precio de Pescado (Merluza en salsa).
"7,50" , //2º- Precio de Pescado (Bacalao al pil-pil).
"12" //3º- Precio de Pescado (Besugo al horno).
},
{ //-- Precios de Postres (4) --
"3" , //1º- Precio de Postre (Tarta al whiski).
"2,50" , //2º- Precio de Postre (Flan).
"2,50" , //3º- Precio de Postre (Helado).
"4" //4º- Precio de Postre (Postre de la casa).
},
{ //-- Precios de Bebidas (6) --
"7" , //1º- Precio de Bebida (Vino blanco).
"8" , //2º- Precio de Bebida (Vino tinto).
"1,50" , //3º- Precio de Bebida (Agua pequeña).
"2,50" , //4º- Precio de Bebida (Agua grande).
"4" , //5º- Precio de Bebida (Cerveza).
"2,50" //6º- Precio de Bebida (Refrescos).
},
{ //-- Precios de Café / Copa (5) --
"1" , //1º- Precio de Café / Copa (Café sólo).
"1,10" , //2º- Precio de Café / Copa (Café cortado).
"1,20" , //3º- Precio de Café / Copa (Café con leche).
"2,20" , //4º- Precio de Café / Copa (Copa de pacharán).
"3,50" //5º- Precio de Café / Copa (Copa de whisky).
};
int iNumTotalPlatos = [Link]; //Número total de platos del
menú.
int NumVariedadesPlatoActual[]; //Número total de variedades del
plato actual.
String sMonedaPrecio = "€"; //Moneda a mostrar en los precios.
Color cRojo = [Link]; //Asignamos el color rojo a la variable de
color cRojo.
Color cVerde = [Link]; //Asignamos el color verde a la variable
de color cVerde.
Color cAzul = [Link]; //Asignamos el color azúl a la variable
de color cAzul.
Color cBlanco = [Link]; //Asignamos el color blanco a la variable
de color cBlanco.
Color cNegro = [Link]; //Asignamos el color negro a la variable
de color cNegro.
Color cCian = [Link]; //Asignamos el color cian a la variable de
color cCian.
ButtonGroup gb[]= new ButtonGroup[iNumTotalPlatos];
JButton b1,b2,b3,b4;
JPanel p,p1,p2,p3,p4,p5,p2i[] = new JPanel[iNumTotalPlatos]; //6 paneles
y uno de tipo array.
JTextArea ta;
JScrollPane jspTextArea; //Hemos cambiado el nombre de la clase tajsp
por jspTextArea.
JScrollPane jsp;
JRadioButton rb[][];//= new
JRadioButton[[Link]][variedades[5].length];
JCheckBox cb[] = new JCheckBox[iNumTotalPlatos];
boolean agotado[][];
BorderLayout bl; //Creamos una capa Borde para poner los
botones de debajo.
Font fNegro,fRojo;
//
public MenuCena()
int i,j;
//Declaramos las variables tipo int para los margenes de la clase
Insets para los 4 botones.
int
iMargenArribaInsetB1,iMargenArribaInsetB2,iMargenArribaInsetB3,iMargenArribaIn
setB4;
int
iMargenIzquierdoInsetB1,iMargenIzquierdoInsetB2,iMargenIzquierdoInsetB3,iMarge
nIzquierdoInsetB4;
int
iMargenAbajoInsetB1,iMargenAbajoInsetB2,iMargenAbajoInsetB3,iMargenAbajoInsetB
4;
int
iMargenDerechoInsetB1,iMargenDerechoInsetB2,iMargenDerechoInsetB3,iMargenDerec
hoInsetB4;
//Establecemos los valores de las variables tipo int para los margenes
de la clase Insets para los 4 botones.
iMargenArribaInsetB1 = 50;
iMargenArribaInsetB2 = 50;
iMargenArribaInsetB3 = 50;
iMargenArribaInsetB4 = 50;
iMargenIzquierdoInsetB1 = 50;
iMargenIzquierdoInsetB2 = 50;
iMargenIzquierdoInsetB3 = 50;
iMargenIzquierdoInsetB4 = 50;
iMargenAbajoInsetB1 = 50;
iMargenAbajoInsetB2 = 50;
iMargenAbajoInsetB3 = 50;
iMargenAbajoInsetB4 = 50;
iMargenDerechoInsetB1 = 50;
iMargenDerechoInsetB2 = 50;
iMargenDerechoInsetB3 = 50;
iMargenDerechoInsetB4 = 50;
//Creamos las 4 instancias de la clase Insets para los 4
botones(estableciendo los márgenes correspondientes con las variables).
Insets insB1= new Insets (
iMargenArribaInsetB1,
iMargenIzquierdoInsetB1,
iMargenAbajoInsetB1,
iMargenDerechoInsetB1
);
Insets insB2= new Insets (
iMargenArribaInsetB2,
iMargenIzquierdoInsetB2,
iMargenAbajoInsetB2,
iMargenDerechoInsetB2
);
Insets insB3= new Insets (
iMargenArribaInsetB3,
iMargenIzquierdoInsetB3,
iMargenAbajoInsetB3,
iMargenDerechoInsetB3
);
Insets insB4= new Insets (
iMargenArribaInsetB4,
iMargenIzquierdoInsetB4,
iMargenAbajoInsetB4,
iMargenDerechoInsetB4
);
bl = new BorderLayout();
//Declaramos las variables tipo int para los números de filas y de
columnas de los paneles p, p1, p2 y p3.
int iNumColumnasP,iNumColumnasP1,iNumColumnasP2,iNumColumnasP3;
int iNumFilasP,iNumFilasP1,iNumFilasP2,iNumFilasP3;
//Establecemos los valores de las variables tipo int para los números
de filas y de columnas de los paneles p, p1, p2 y p3.
iNumColumnasP = 1;
iNumColumnasP1 = 1;
iNumColumnasP2 = iNumTotalPlatos;
iNumColumnasP3 = 1;
// iNumColumnasP4 = 1;
iNumFilasP = 4;
iNumFilasP1 = 1;
iNumFilasP2 = 1;
iNumFilasP3 = 1;
// iNumFilasP4 = 1;
p = new JPanel(new GridLayout(iNumFilasP,iNumColumnasP));
p1 = new JPanel(new GridLayout(iNumFilasP1,iNumColumnasP1));
p2 = new JPanel(new GridLayout(iNumFilasP2,iNumColumnasP2));
p3 = new JPanel(new GridLayout(iNumFilasP3,iNumColumnasP3));
p4 = new JPanel(bl); //new GridLayout(1,1));
for(i=0;i<iNumTotalPlatos;i++)
p2i[i] = new JPanel (
new GridLayout (
iNumTotalPlatos,
);
p2i[i].setBorder (
[Link] (
[Link](),
platos[i].toString()
);
// panel 1
for(i=0; i<[Link]; i++)
{
cb[i]= new JCheckBox(platos[i]);
cb[i].addItemListener(this);
cb[i].setBackground(cVerde);
[Link](cb[i]);
// panel 2
rb= new JRadioButton[iNumTotalPlatos][];
agotado = new boolean[iNumTotalPlatos][];
for(i=0; i<iNumTotalPlatos; i++)
{ rb[i] = new JRadioButton[iNumTotalPlatos];
agotado[i] = new boolean[iNumTotalPlatos];
}
for(i=0; i<iNumTotalPlatos; i++)
gb[i] = new ButtonGroup();
int iNumVariedadesPlatoActual = variedades[i].length;
for (j=0; j<iNumVariedadesPlatoActual; j++)
rb[i][j] = new JRadioButton(variedades[i][j],false);
agotado[i][j]= false;
rb[i][j].addItemListener(this);
rb[i][j].setEnabled(false);
gb[i].add(rb[i][j]);
p2i[i].add(rb[i][j]);
rb[i][j].setBackground(cCian);
//Establecemos el mensaje de ayuda que aparece en el
radiobutton correspondiente.
rb[i][j].setToolTipText (
variedades[i][j] +
" ...... " +
precio[i][j] +
sMonedaPrecio +
" (IVA no incluido). "
);
rb[i][0].setSelected(true);
[Link](p2i[i]);
}
// Panel 3 �rea de texto.
Color cColorFondoPanelTextArea = cVerde; //Asignamos el color de
fondo a la variable para poner el color de fondo del panel del �rea de texto.
String sTituloBorderFactoryJTextArea = "MENÚ ELEGIDO"; //Añadimos
una variable donde pondremos el texto que aparecerá en el tÃtulo del borde
del �rea de texto.
ta = new JTextArea("-- CAFETERIA CANDY -- \n - Elija un
menú.",15,40);
[Link](cColorFondoPanelTextArea);
//Establecemos el borde del Ã�rea de texto y le añadimos un tÃtulo.
[Link] (
[Link] (
[Link] (
[Link]
),
sTituloBorderFactoryJTextArea
); //createEtchedBorder(),"MENU ELEGIDO"));
[Link](false);
//Añadimos el panel con las barras de desplazamiento al �rea de
texto.
jspTextArea = new JScrollPane(ta);
// try
// {
//Ponemos la propieddad de la forma en que se muestran las barras
de desplazamiento del �rea de Texto.
[Link](JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDE
D);
[Link](JScrollPane.HORIZONTAL_SCROLLBAR_AS_N
EEDED);
// }
// catch(IllegalArgumentException iae)
// {
// [Link]("Argumento ilegal");
// }
//Creamos unas variables de tipo String para poner el texto de los
botones del panel p4.
String sTextoB1,sTextoB2,sTextoB3,sTextoB4;
sTextoB1 = "SELECCIONAR";
sTextoB2 = "DE ESTO NO QUEDA";
sTextoB3 = "REPONER";
sTextoB4 = "SALIR";
b1 = new JButton(sTextoB1);
b2 = new JButton(sTextoB2);
b3 = new JButton(sTextoB3);
b4 = new JButton(sTextoB4);
[Link](cAzul);
[Link](cBlanco);
[Link](cRojo);
[Link](cNegro);
[Link](cBlanco);
[Link](cRojo);
[Link](insB1);
[Link](insB2);
[Link](insB3);
[Link](this);
[Link](this);
[Link](this);
[Link]
new ActionListener()
public void actionPerformed( ActionEvent aeExit)
[Link](0);
);
[Link](b1,[Link]);
[Link](b2,[Link]);
[Link](b3,[Link]);
[Link](b4,[Link]);
[Link](jspTextArea);// area de texto con deslizadores.
[Link](p1);
[Link](p2);
[Link](p3);
[Link](p4);
[Link]().add(p);
public void itemStateChanged(ItemEvent ie)
Object obj;
obj=[Link]();
if (obj instanceof JCheckBox)
{
for(int i=0;i<iNumTotalPlatos;i++)
if((JCheckBox)[Link]()==cb[i])
if(((JCheckBox)obj).isSelected())
activarBotonera(i,variedades[i].length, true);
else
activarBotonera(i,variedades[i].length,false);
private void activarBotonera(int k,int n,boolean sw)
for(int i=0; i<n;i++)
if(sw && !agotado[k][i])
rb[k][i].setEnabled(true);
else
rb[k][i].setEnabled(false);
public void actionPerformed(ActionEvent ae)
//Declaramos las variables
double tot,x;
int i,j;
int
iLongitudPrecioConceptoActualEnCadena,iLongitudPrecioTotalEnCadena,iLongitudIV
ATotalEnCadena,iLongitudFacturaEnCadena;
NumberFormat formato;
//Creamos una nueva instancia de la clase formato
formato = [Link]();
//Establecemos las propiedades de la instancia de NumberFormat formato
[Link](2);
[Link](2);
//[Link](3);
if([Link]() instanceof JButton)
if(((JButton)[Link]())==b1) // SELECCIONAR
{ // borrar pantalla previa
[Link]("");
//inicializar variables
tot = 0;
for(i=0;i<iNumTotalPlatos;i++)
if(cb[i].isSelected())
for(j=0; j<variedades[i].length;j++)
if(!agotado[i][j] &&
rb[i][j].isSelected())
{
x =
[Link](precio[i][j].replace(',', '.'));
iLongitudPrecioConceptoActualEnCadena
= [Link](x).toString().trim().length();
[Link]("Precio de concepto " +
(i+1) + ": \t");
if
(iLongitudPrecioConceptoActualEnCadena <= 4)
[Link](" ");
else
if
(iLongitudPrecioConceptoActualEnCadena > 5)
[Link](".");
[Link]([Link](x));
[Link](sMonedaPrecio + " | " +
rb[i][j].getText() + " (" + cb[i].getText() + ")." + "\n");
tot += x;
double iva = tot*.10;
// iLongitudPrecioTotalEnCadena
// iLongitudIVATotalEnCadena
// iLongitudFacturaEnCadena
for (i = 0; i <= 54; i++)
[Link]("-");
[Link]("|");
[Link]("\n");
[Link]("PRECIO TOTAL");
for (i = 0; i <= 10; i++)
[Link](" ");
[Link]("= \t");
iLongitudPrecioTotalEnCadena =
[Link](tot).toString().trim().length();
if (iLongitudPrecioTotalEnCadena <= 4)
[Link](" ");
else
if (iLongitudPrecioTotalEnCadena > 5)
[Link](".");
[Link]([Link](tot));
[Link](sMonedaPrecio + " | " + "\n");
[Link](" IVA (10%)");
for (i = 0; i <= 20; i++)
[Link](" ");
[Link]("= \t");
//[Link](cRojo);
iLongitudIVATotalEnCadena =
[Link](iva).toString().trim().length();
if (iLongitudIVATotalEnCadena <= 4)
[Link](" ");
else
if (iLongitudIVATotalEnCadena > 5)
[Link](".");
[Link]([Link](iva));
[Link](sMonedaPrecio + " | " + "\n");
for (i = 0; i <= 54; i++)
[Link]("-");
[Link]("|");
[Link]("\n");
[Link]("TOTAL FACTURA");
for (i = 0; i <= 5; i++)
{
[Link](" ");
[Link]("= \t");
iLongitudFacturaEnCadena =
[Link](tot+iva).toString().trim().length();
if (iLongitudFacturaEnCadena <= 4)
[Link](" ");
else
if (iLongitudFacturaEnCadena > 5)
[Link](".");
[Link]([Link](tot+iva));
[Link](sMonedaPrecio + " | ");
repaint();
[Link](cAzul);
else if(((JButton)[Link]()) == b2) // AGOTADO
{
for(i=0;i<iNumTotalPlatos;i++)
if(cb[i].isSelected())
for(j=0; j<variedades[i].length;j++)
if( rb[i][j].isSelected())
{ agotado[i][j] =true;
rb[i][j].setEnabled(false);
else if(((JButton)[Link]()) == b3) // REPONER
for(i = 0; i < iNumTotalPlatos; i++)
if( cb[i].isSelected() )
for(j=0; j<variedades[i].length;j++)
// reponer todos.
// if(!rb[i][j].isEnabled() &&
agotado[i][j]) // no se pueden seleccionar si desactivados
// {
agotado[i][j] =false;
rb[i][j].setEnabled(true);
// }
}
public static void main(String[]args)
MenuCena mn= new MenuCena();
[Link]
new WindowAdapter()
public void windowClosing(WindowEvent we)
{
[Link](1);
);
[Link](1000,770);
[Link](false);
[Link](true);
Este simple código muestra como indicar si los valores de un array son pares o impares de forma recursiva.
public class Main {
/**
* la función recursiva parImpar muestra por pantalla los valores del
array
* indicando si son par o impar
*/
static int parImpar (int t[], int pos)
int res;
if(pos<[Link]) {
if(t[pos]%2==0)
[Link]("El valor "+t[pos]+" es par");
}else{
[Link]("El valor "+t[pos]+" es impar");
parImpar(t,pos+1);
return 1;
/**
* el usuario utilizará esta función por comodidad
* recibe un array de valores enteros
*/
static int parImpar (int t[])
return (parImpar (t,0));
public static void main(String[] args) {
// Definimos el array
int datos[]={1,2,3,4,5,6,7,8,9};
parImpar(datos);
}
Este simple código muestra como sumar un array de valores de forma recursiva.
ublic class Main {
/**
* Esta función recursiva, suma los elementos de un array y devuelve el
total
*/
static int sumar (int t[], int pos)
if(pos<[Link]) {
return t[pos]+sumar(t,pos+1);
return 0;
public static void main(String[] args) {
// Definimos el array
int datos[]={1,2,3,-2};
[Link]("La suma del array es: "+sumar(datos,0));
Hay que pasar como parametro el numero máximo de asteriscos.
public class Triangulo {
// Tiene que recibir la cantidad máxima de valores a mostrar
// Siempre sera un valor impar
public static void main(String[] args)
// obtenemos el valor recibido
int max=new Integer(args[0]);
int i=0,j=0;
for(i=1;i<=max;i=i+1)
// Mostramos los asteriscos en cada fila
for(j=0;j<i;j++)
[Link]("*");
[Link]();
mplementar un programa que permita gestionar los gastos de "n" días de una persona. Se deberá mostrar el
total de gastos y que día se hizo el mayor gasto.
package Pago_Gastos;
import [Link];
public class DiaPagoMayor {
//Atributos:
static Scanner teclado = new Scanner([Link]);
public static void main(String[] args) {
//Solicitamos la cantidad de dias a procesar:
[Link]("Ingrese la cantidad de dias: ");
int cantDias = [Link]();
int[] vector = new int[cantDias];
int gastomayor = 0, gastoTotal = 0, dia = 0;
String[] strDias = new String[7];
strDias[0] = "Lunes";
strDias[1] = "Martes";
strDias[2] = "Miercoles";
strDias[3] = "Jueves";
strDias[4] = "Viernes";
strDias[5] = "Sabado";
strDias[6] = "Domingo";
//Creamos un ciclo for para repetir los datos segun la cantidad de
dias:
for (int i = 0; i < cantDias; i++){
[Link]("Ingrese los gastos del dia " + strDias[i%7] + ":
" );
vector[i] = [Link]();
for (int i = 0; i < cantDias; i++){
[Link](vector[i]);
gastoTotal += vector[i];
if (vector[i] > gastomayor){
gastomayor = vector[i];
dia = i;
[Link]("El mayor gasto fue de " + gastomayor + " del dia "
+ strDias[dia] );
[Link]("El gasto total fue de: " + gastoTotal );
Factorial de un numero
import [Link].*;
public class Main {
static int factorial(int num){
int res;
if(num==0) // caso base: 0! es igual a 1
res=1;
else
res=num*factorial(num-1); // n!= n*(n-1)*(n-2)... un ejemplo 3!=3*2*1
// tambien ocurre que n!=n*(n-1)!
// como ejemplo 4!=4*3!
return(res);
public static void main(String[] args) {
int num,resultado;
[Link]("Introduzca el numero: ");
num=entero();
resultado=factorial(num);
[Link](num+"! es igual a "+resultado);
static int entero(){
int valor=[Link](inicializar());
return valor;
static String inicializar(){
String buzon="";
InputStreamReader flujo=new InputStreamReader([Link]);
BufferedReader teclado=new BufferedReader(flujo);
try{
buzon=[Link]();
}
catch(Exception e){
[Link]("Entrada incorrecta)");
return buzon;