+ 2
Result is blank, what now?
I made this program to find middle character in the string. But how can i change it if the result is blank space i want the program to write instead of blank space - # or something else, just not blank. https://code.sololearn.com/c2fLZt1Pn4NY/?ref=app
5 odpowiedzi
+ 5
a space is a character so you could check the result with somthing like
if(strResult.equals(" ")){System.out.print("The middle character is a space");}
+ 4
Winter Wolf your welcome 😉👍
+ 2
okay i made it kinda your way. u made me do it like this
if(midChar(letters).equals(" ")){
System.out.println("The middle character is: space " + midChar(letters));
}
else
{
System.out.println("The middle character is: " + midChar(letters));
}
thanks a lot :)
+ 1
i forget there can be 2x space if the string is even so it will be
if(midChar(letters).equals(" "))
{
System.out.println("The middle character is: space " + midChar(letters));
}
else if (midChar(letters).equals(" "))
{
System.out.println("The middle character is: space space" + midChar(letters));
}
else
{
System.out.println("The middle character is: " + midChar(letters));
}
}
thank you
+ 1
there are few options of results
char
char char
space
space space
space char
char space
so i made that every space(" ") will be shown as #
it was fun by working on this i made a lot of mistakes but finally got it thank you :)
if(midChar(letters).equals(" "))
{
System.out.println("The middle character is: " + midChar(letters).replace(' ', '#'));
}
else
{
System.out.println("The middle character is: " + midChar(letters).replace(' ', '#'));
}