changing case

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spud379
    New Member
    • Mar 2007
    • 11

    changing case

    hi
    i'm trying to write this programme i think im nearly there. if its lower case i want to change it to upper and Visor verse. this also includes in the same word. eg

    Hi tHeRE = hI ThEre

    String a = args[0];
    do
    {
    if (????????)
    a = a.toUpperCase() ;
    else
    a = a.toLowerCase() ;
    }
    while(????)
    System.out.prin tln(a)
    }


    this is what i think not sure what to put in the IF statement. can any 1 help?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by spud379
    hi
    i'm trying to write this programme i think im nearly there. if its lower case i want to change it to upper and Visor verse. this also includes in the same word. eg

    Hi tHeRE = hI ThEre

    String a = args[0];
    do
    {
    if (????????)
    a = a.toUpperCase() ;
    else
    a = a.toLowerCase() ;
    }
    while(????)
    System.out.prin tln(a)
    }

    this is what i think not sure what to put in the IF statement. can any 1 help?
    Since you should be looking at the statements character by character, you may want to to use the charAt method of the String class in conjuction with the methods of the character class.

    Comment

    Working...