Advertisement
BassDrop

Denis Dimchev 24/01/2020 ES 39

Jan 24th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. Scanner input = new Scanner(System.in);
  9. char[] index = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  10. char[] numIndex = {'0','9','8','7','6','5','4','3','2','1'};
  11. String parola = input.nextLine();
  12. int sizeWord = parola.length();
  13. int sizeArray = index.length;
  14. int sizeNumArray = numIndex.length;
  15. int numeri =0;
  16. int lettere =0;
  17.  
  18. for(int j=0;j<sizeArray;j++) {
  19. for (int i = 0; i < sizeWord; i++) {
  20. if(parola.charAt(i) == index[j]) {
  21. lettere++;
  22. }
  23. }
  24. }
  25. for(int j=0;j<sizeNumArray;j++) {
  26. for (int i = 0; i < sizeWord; i++) {
  27. if (parola.charAt(i) == numIndex[j]) {
  28. numeri++;
  29. }
  30. }
  31. }
  32. System.out.println("Le lettere sono " + lettere);
  33. System.out.println("I numeri sono " + numeri);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement