Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ChangeCase
- {
- public static void main(String[] ar)
- {
- Scanner a = new Scanner(System.in);
- System.out.println("Enter a string with jumbled cases");
- String b = a.nextLine();
- int c = b.length();
- String i = "";
- for (int d = 0; d < c; d++)
- {
- char e = b.charAt(d);
- boolean f = Character.isUpperCase(e);
- boolean g = Character.isLowerCase(e);
- if (f)
- {
- char h = Character.toLowerCase(e);
- i += h;
- } else if (g)
- {
- char j = Character.toUpperCase(e);
- i += j;
- } else if (f == false && g == false)
- {
- i += e;
- }
- }
- System.out.println("The output is '" + i + "'");
- }
- }
Add Comment
Please, Sign In to add comment