-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringIntroduction.java
More file actions
24 lines (18 loc) · 886 Bytes
/
StringIntroduction.java
File metadata and controls
24 lines (18 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package HackerRank.Introduction;
import java.util.Scanner;
public class StringIntroduction {
public static void main(String[] args) {
/*
* [ ] For the first line, sum the lengths of A and B.
* [ ] For the second line, write Yes if A is lexicographically greater than B otherwise print No instead.
* [ ] For the third line, capitalize the first letter in both A and B and print them on a single line, separated by a space.
* */
Scanner sc =new Scanner(System.in);
String A = sc.next();
String B = sc.next();
System.out.println((A + B).length());
boolean compared = A.compareTo(B) > B.compareTo(A);
System.out.println(compared ? "Yes" : "No");
System.out.println(A.substring(0,1).toUpperCase()+A.substring(1) + " " + B.substring(0,1).toUpperCase() + B.substring(1));
}
}