Files
HackerRank-Solutions/Java/Strings/Java Strings Introduction/Solution.java
T

34 lines
947 B
Java
Raw Normal View History

2017-02-12 00:31:12 -08:00
// Author: Rodney Shaghoulian
// Github: github.com/rshaghoulian
// HackerRank: hackerrank.com/rshaghoulian
2017-02-07 01:14:49 -08:00
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
/* Read input */
Scanner scan = new Scanner(System.in);
String A = scan.next();
String B = scan.next();
scan.close();
/* Sum lengths */
System.out.println(A.length() + B.length());
/* Compare lexicographical ordering */
System.out.println(A.compareTo(B) > 0 ? "Yes" : "No");
/* Print the Strings in desired format */
System.out.println(capFirstLetter(A) + " " + capFirstLetter(B));
}
private static String capFirstLetter(String str) {
if (str == null || str.length() == 0) {
return "";
} else {
return str.substring(0,1).toUpperCase() + str.substring(1);
}
}
}