You are on page 1of 1

//Jonathan Fernandez 8-1007-1530

//Edwin Gonzalez 2-715-2144


import java.io.*;

public class Main {


public static void main(String[] args) {
String s = "";
String c;
int l;
int i = 0;
int j = 0;
int z = 0;
boolean error = true;

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

do{
try{
System.out.println("Introduzca la cadena: ");
s = (br.readLine());
error = false;
}
catch (IOException x){
System.out.println("Hubo un error en la io" + x);
error = true;
}
}while (error);
l = s.length();
if(l%2 == 1){
c = s.substring((l/2),(l/2)+1);
}else{
c = s.substring(((l/2)-1),((l/2)+1));
}
z = 1;
for (i = 0; i <= l; i++){
for(j = z; j <= l; j++){
System.out.println(s.substring(i,j));
}
z = z + 1;
}

System.out.println("La longitud de la cadena \"" + s + "\" es de: "+ l);


System.out.println("El elemento medio de \"" + s + "\" es: "+ c);
}
}

You might also like