Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void exerciciod(String str) {
- String l = "ll";
- while (l.length() > 1) {
- l = JOptionPane.showInputDialog("Digite um caracter");
- }
- int letras = 0;
- int qtd = 0;
- String[] split = str.split(" ");
- int n = split.length;
- for (int i = 0; i <= n - 1; i++) {
- if (split[i].startsWith(l)) {
- letras += split[i].length();
- qtd++;
- }
- }
- if (qtd != 0) {
- int f = letras / qtd;
- System.out.println(f);
- } else {
- System.out.println("Nenhuma palavra iniciou com este caracter.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement