Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static int numbers(int number, int digit) {
- int res = 0;
- while (number > 0) {
- if (number % 10 == digit) {
- res += 1;
- }
- number /= 10;
- }
- System.out.println(res);
- return res;
- }
- public static void main (String[]args){
- Scanner s = new Scanner(System.in);
- System.out.println("please enter a number");
- int num = s.nextInt();
- int digi = s.nextInt();
- numbers(num, digi);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement