CanYouReadThis? [codingblocks]
One of the important aspect of object oriented programming is readability of the code. To enhance the readability of code, developers write function and variable names in Camel Case. You are given a string, S, written in Camel Case. FindAllTheWordsContainedInIt.
Input Format
A single line contains the string.
Constraints
|S|<=1000
Output Format
Print words present in the string, in the order in which it appears in the string.
Sample Input
IAmACompetitiveProgrammer
Sample Output
I
Am
A
Competitive
Programmer
Explanation
There are 5 words in the string.
JAVA code:
IDE Code: https://ide.geeksforgeeks.org/qCrXFRPZ8x
/* Amit Kumar 14-12-2020 IDE Code: https://ide.geeksforgeeks.org/qCrXFRPZ8x */ package String; import java.util.Scanner; public class String_CanYouReadThis { public static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { String str = scanner.next(); int i; int start = 0; int end = 0; boolean flag = false; for (i=0; i<str.length(); i++) { if (Character.isUpperCase(str.charAt(i))) { if (flag) { end = i; System.out.println(str.substring(start, end)); start = i; } else { start = i; flag = true; } } } System.out.println(str.substring(start)); } }
Comments
Post a Comment