You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNextLine()){ String ss=sc.nextLine(); char op =ss.charAt(0); char ot=ss.charAt(2); StringBuilder result = new StringBuilder(); if(op=='S'){ for(int i=4;i<ss.length();i++){ char currentChar = ss.charAt(i); if(Character.isUpperCase(currentChar) && i>4){ result.append(" "); } result.append(Character.toLowerCase(currentChar)); } if(ot=='M' && ss.charAt(ss.length()-1)==')'){ result.delete(ss.length()-5, ss.length()-3); result.toString().toLowerCase(); } System.out.println(result); } else if(op=='C'){ int j=0; for(int i=4;i<ss.length();i++){ char currentChar = ss.charAt(i); if(currentChar==' '){ j=i+1; continue; } if(j==i){ result.append(Character.toUpperCase(currentChar)); continue; } result.append(currentChar); } if(ot=='M'){ result.append('('); result.append(')'); } if(ot=='C'){ String res=result.substring(0,1).toUpperCase() +result.substring(1); System.out.println(res); continue; } System.out.println(result); } } }}
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {