Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static jdk.nashorn.internal.objects.NativeString.toUpperCase;
- public class _21_Change_to_sentenceToUppercase {
- public static void main(String[] args) {
- Scanner scanIn = new Scanner(System.in);
- String text = scanIn.nextLine();
- String openTag = "<upcase>";
- String closeTag = "</upcase>";
- String modified = "";
- for (int i = 0; i < text.length(); i++) {
- int indexOpen = text.indexOf(openTag, i);
- int indexClose = text.indexOf(closeTag, i);
- if (i == indexOpen)
- {
- if (indexOpen != -1 && indexClose != -1)
- {
- for (int j = indexOpen + openTag.length(); j < indexClose; j++)
- {
- modified += text.toUpperCase().charAt(j);
- }
- i += indexClose - indexOpen + closeTag.length();
- }
- }
- if (i < text.length())
- {
- modified += text.charAt(i);
- }
- }
- System.out.print(modified);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement