Advertisement
16112

Курсова Работа 2 - 5.5б Пунктуация

May 12th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pet_Pet_B {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         char[] array = sc.nextLine().toCharArray();
  8.         punctuation(array);
  9.     }
  10.  
  11.     public static void punctuation(char[] array) {
  12.         for (int i = array.length - 1; i >= 0; --i) {
  13.             if (Character.isLowerCase(array[i]))
  14.                 System.out.print(Character.toUpperCase(array[i]));
  15.             else if (Character.isUpperCase(array[i]))
  16.                 System.out.print(Character.toLowerCase(array[i]));
  17.             else if (Character.isDigit(array[i]))
  18.                 System.out.print(Character.getNumericValue(array[i]) * 2);
  19.             else {
  20.                 switch (array[i]) {
  21.                 case ' ':
  22.                 case '!':
  23.                 case '#':
  24.                 case '%':
  25.                 case '&':
  26.                 case '(':
  27.                 case ')':
  28.                 case '*':
  29.                 case '-':
  30.                 case '.':
  31.                 case ':':
  32.                 case ',':
  33.                 case '?':
  34.                 case '@':
  35.                 case '[':
  36.                 case ']':
  37.                 case '_':
  38.                 case '{':
  39.                 case '}':
  40.                     System.out.print(".");
  41.                     break;
  42.                 }
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement