Skip to content

Commit 8e0f3ff

Browse files
committed
Solution to find the number of Occurences of a Number
1 parent 55afe52 commit 8e0f3ff

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎src/Assignments/CountNums.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Assignments;
2+
3+
import java.util.Scanner;
4+
5+
public class CountNums {
6+
public static void main(String[] args) {
7+
Scanner input = new Scanner(System.in);
8+
System.out.println("Enter the number to find: ");
9+
int number = input.nextInt();
10+
Scanner input_2 = new Scanner(System.in);
11+
int searchNumber = input.nextInt();
12+
System.out.println("Enter the number to find: ");
13+
14+
int count = 0;
15+
16+
while (number > 0){
17+
int reminder = number % 10;
18+
if (reminder == searchNumber){
19+
count ++;
20+
}
21+
number = number/10;
22+
}
23+
System.out.println("Count is " + count);
24+
}
25+
}

0 commit comments

Comments
 (0)