0

hey guys im kinda new to java n want ur help in solvin this problem :

post: all of the "letter" characters in the entered string will have been switched (lowercase to uppercase, vice versa)

i can only use for loops, character class methods, string methods

heres my code but it doesn't seem to works can u guys fix it ? thnx

public static String switchCase(String s3) 
char c 
{
for ( int i = 0; i == s3.length() -1; i++)
   {
    if (Character.isLowerCase(s3.charAt(i)) == true)
    {
     c = Character.toUpperCase(s3.charAt(i));
     s3 = s3.replace(s3.charAt(i), c); 
    }
    else if (Character.isUpperCase(s3.charAt(i)) == true)
    {
     c = Character.toLowerCase(s3.charAt(i));
     s3 = s3.replace(s3.charAt(i), c); 
}
    }

Edited by privatestatic: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pbl
0

By the way, to respect universal practive by C/C++/Java/Fortran programmers

for ( int i = 0; i == s3.length() -1; i++)

should be

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.