Advertisement
dimitrova_elka

ChangeToUppercase

Aug 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChangeToUppercase {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String text = scanner.nextLine();
  7.         while (text.contains("<upcase>")) {
  8.             int indexOfUpcase = text.indexOf("<upcase>");
  9.             int indexEndUpcase = text.indexOf("</upcase>");
  10.             String uppercasedText = text.substring(indexOfUpcase + 8, indexEndUpcase).toUpperCase();
  11.             String textToReplace = text.substring(indexOfUpcase, indexEndUpcase + 9);
  12.             text = text.replace(textToReplace, uppercasedText);
  13.         }
  14.         System.out.println(text);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement