Advertisement
yani-valeva

ChangeToUppercase

Jul 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class ChangeToUppercase {
  6. public static void main(String[] args) throws IOException {
  7. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  8.  
  9. String text = reader.readLine();
  10. String start = "<upcase>";
  11. String end = "</upcase>";
  12.  
  13. int startIndex = text.indexOf(start);
  14. int endIndex = text.indexOf(end);
  15.  
  16. while (startIndex >= 0 && endIndex >= 0) {
  17. String replacement = text.substring(startIndex + start.length(), endIndex).toUpperCase();
  18. String oldPartOfText = text.substring(startIndex, endIndex + end.length());
  19. text = text.replace(oldPartOfText, replacement);
  20. startIndex = text.indexOf(start, startIndex + 1);
  21. endIndex = text.indexOf(end, endIndex + 1);
  22. }
  23.  
  24. System.out.println(text);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement