Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- 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'};
- char[] numIndex = {'0','9','8','7','6','5','4','3','2','1'};
- String parola = input.nextLine();
- int sizeWord = parola.length();
- int sizeArray = index.length;
- int sizeNumArray = numIndex.length;
- int numeri =0;
- int lettere =0;
- for(int j=0;j<sizeArray;j++) {
- for (int i = 0; i < sizeWord; i++) {
- if(parola.charAt(i) == index[j]) {
- lettere++;
- }
- }
- }
- for(int j=0;j<sizeNumArray;j++) {
- for (int i = 0; i < sizeWord; i++) {
- if (parola.charAt(i) == numIndex[j]) {
- numeri++;
- }
- }
- }
- System.out.println("Le lettere sono " + lettere);
- System.out.println("I numeri sono " + numeri);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement