Advertisement
Yahya-Ak-Ayoub

CCheckTheText

Mar 19th, 2021
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1.  
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import javafx.beans.binding.StringBinding;
  6.  
  7. public class CCheckTheText {
  8.  
  9.     public static void main(String[] args) throws IOException {
  10.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  11.  
  12.         int numberOfWords = Integer.parseInt(reader.readLine());
  13.         String words = reader.readLine();
  14.  
  15.         int numberOfLines = Integer.parseInt(reader.readLine());
  16.  
  17.         String input, result = "";
  18.  
  19.         boolean flag = false;
  20.         for (int i = 0; i < numberOfLines; i++) {
  21.             input = reader.readLine().toLowerCase();
  22.  
  23.             if ("capslock".equals(input)) {
  24.                 flag = !flag;
  25.                 continue;
  26.             } else if ("backspace".equals(input)) {
  27.                 if (result.length() != 0) {
  28.                     result = result.substring(0, result.length() - 1);
  29.                 }
  30.                 continue;
  31.             } else if ("space".equals(input)) {
  32.                 result += " ";
  33.                 continue;
  34.             }
  35.  
  36.             if (flag) {// true capital
  37.                 result += input.toUpperCase();
  38.             } else {// false small
  39.                 result += input.toLowerCase();
  40.             }
  41.         }
  42.         System.out.println(words.equals(result) ? "Correct" : "Incorrect");
  43.  
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement