-
Notifications
You must be signed in to change notification settings - Fork 0
/
Let_cnt.java
26 lines (24 loc) · 1017 Bytes
/
Let_cnt.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;
public class Let_cnt {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Welcome to my program! This program help you to count repetion of character in a string.");
System.out.print("Enter your name : ");
String name = scan.nextLine();
System.out.println("Lets, begin " + name);
System.out.println("#############################################################");
String str1 = "The quick brown fox jumps over the lazy dog";
System.out.println(str1);
int count =0;
System.out.print("Enter the character : ");
char c = scan.nextLine().charAt(0);
for (int i = 0; i < str1.length(); i++) {
char ch = str1.charAt(i);
if (c == ch){
count += 1;
}
}
System.out.print(c + " is " + count + " times in the given string.");
scan.close();
}
}