Added 27 solutions
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Author: Rodney Shaghoulian
|
||||
// Github: github.com/rshaghoulian
|
||||
// HackerRank: hackerrank.com/rshaghoulian
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Solution {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
String str = scan.next();
|
||||
scan.close();
|
||||
System.out.println(numWords(str));
|
||||
}
|
||||
|
||||
private static int numWords(String str) {
|
||||
int count = 1;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char ch = str.charAt(i);
|
||||
if (ch >= 'A' && ch <= 'Z') {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user