KAKAN

Java sisha

Sep 22nd, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChangeCase
  4.  
  5. {
  6.  
  7.  public static void main(String[] ar)
  8.  
  9.  {
  10.  
  11.   Scanner a = new Scanner(System.in);
  12.  
  13.   System.out.println("Enter a  string  with  jumbled  cases");
  14.  
  15.   String b = a.nextLine();
  16.  
  17.   int c = b.length();
  18.   String i = "";
  19.  
  20.   for (int d = 0; d < c; d++)
  21.  
  22.   {
  23.  
  24.    char e = b.charAt(d);
  25.  
  26.    boolean f = Character.isUpperCase(e);
  27.  
  28.    boolean g = Character.isLowerCase(e);
  29.  
  30.    if (f)
  31.  
  32.    {
  33.  
  34.     char h = Character.toLowerCase(e);
  35.  
  36.     i += h;
  37.  
  38.    } else if (g)
  39.  
  40.    {
  41.  
  42.     char j = Character.toUpperCase(e);
  43.  
  44.     i += j;
  45.  
  46.    } else if (f == false && g == false)
  47.  
  48.    {
  49.     i += e;
  50.  
  51.    }
  52.  
  53.   }
  54.  
  55.   System.out.println("The output  is  '" + i + "'");
  56.  
  57.  }
  58.  
  59. }
Add Comment
Please, Sign In to add comment