@@ -0,0 +1,1506 @@
+package java_problems.beginner;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Kostya likes the number 4 much. Impressed by the power of this number, Kostya%0D%0A * has begun to look for occurrences of four anywhere. He has a list of T%0D%0A * integers, for each of them he wants to calculate the number of occurrences of%0D%0A * the digit 4 in the decimal representation. He is too busy now, so please help%0D%0A * him.%0D%0A * Input%0D%0A * %0D%0A * The first line of input consists of a single integer T, denoting the number%0D%0A * of integers in Kostya's list.%0D%0A * Then, there are T lines, each of them contain a single integer from the list.%0D%0A * %0D%0A * Output: %0D%0A * Output T lines. Each of these lines should contain the number of occurrences%0D%0A * of the digit 4 in the respective integer from Kostya's list.%0D%0A * %0D%0A * Constraints: %0D%0A * 1 %3C= T %3C= 105%0D%0A * (Subtask 1): 0 %3C= Numbers from the list %3C= 9 - 33 points.%0D%0A * (Subtask 2): 0 %3C= Numbers from the list %3C= 10%5E9 - 67 points.%0D%0A * %0D%0A * Example %0D%0A * Input:%0D%0A * 5%0D%0A * 447474%0D%0A * 228%0D%0A * 6664%0D%0A * 40%0D%0A * 81%0D%0A * %0D%0A * Output:%0D%0A * 4%0D%0A * 0%0D%0A * 1%0D%0A * 1%0D%0A * 0%0D%0A */%0D%0Apublic class LuckyFour %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0D%0A%09%09for (int i = 0; i%3C numCases; i++) %7B%0D%0A%09%09%09String number = sc.nextLine();%0D%0A%09%09%09int numFours = 0;%0D%0A%09%09%09for (int j = 0; j %3C number.length(); j++) %7B%0D%0A%09%09%09%09if (number.charAt(j) == '4') %7B%0D%0A%09%09%09%09%09numFours++;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%09System.out.println(numFours);%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%7D

Add LuckyFour