Java program to find middle element of string

Java program to find the middle element of the string. This program will print the center element in this input. Write a Java program┬áthat reads a string from the user and retrieves the middle characters in the string’s center from the input string and returns it as a string output.

import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the string");
String str = sc.nextLine();
char ch[] = str.toLowerCase().toCharArray();
int c=0;
int v=0;
String sp="";
if(str.length()<3)
{
System.out.println("The string should not have "+str+" is too short");
}
else{

for (int i=0;i<ch.length;i++) {

if (ch[i] >= 'a' && ch[i] <= 'z') {
c++;
} else {
sp += ch[i];
v++;
}

}
if(ch.length!=c)
{
System.out.println("this string shouldnt have");
System.out.println(sp);
}
else if(ch.length==c){
System.out.println("middle charecters");
if(ch.length%2==0){
String out = ""+ch[(ch.length/2)-1]+ch[(ch.length/2)];
System.out.println(out);
}
else{
String out = ""+ch[ch.length/2];
System.out.println(out);
}
}

}
}
}

Output:

Enter the string
thilagar
middle charecters
la