Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java help (I know, I know java sux lol)

Name: Anonymous 2010-06-18 17:28

I'm trying to take a line in single character input and if it's uppercase, switch it to lower case and vice versa.
System.out.print ("Enter character: "); 
             s=stdin.readLine();
             c[i]=s.charAt(0);
             k=(int)c[i];
             if(k>96)
        {
                Character.toUpperCase(c[i]);
        }
             else
        {  
                Character.toLowerCase(c[i]);
        } 
             i++;
         }
         while(k!=46);

Everything else works right, but that doesn't flip it. HALP
<3

Name: Anonymous 2010-06-18 18:56

String cases = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", c = "";
BufferedReader cin = new BufferedReader(new InputStreamReader(System.io));
int i = 0;
do
{
   System.out.print("Enter character: ");
   try
   {
      c = "" + (char)cin.read(); // Possible loss of precision?
   }
   throw(IOException e) { break; }
   if((i = cases.indexOf(c)) != -1)
   {
      c = (i >= 26 ? c.toLowerCase() : c.toUpperCase());
      System.out.println(c);
   }
}
while(i != -1);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List