8000 Add files via upload · sumajali/Java-Programs@e33f4fd · GitHub
[go: up one dir, main page]

Skip to content

Commit e33f4fd

Browse files
authored
Add files via upload
1 parent 7effa03 commit e33f4fd

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

String/CountChar.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.Scanner;
2+
3+
public class CountChar{
4+
public static void main(String... arg){
5+
Scanner sc = new Scanner(System.in);
6+
System.out.println("Enter the String: ");
7+
String s=sc.nextLine();
8+
sc.close();
9+
int count=0;
10+
char res=' ';
11+
String x="";
12+
char[] c=s.toCharArray();
13+
for(int j=0;j<s.length();j++){
14+
for(int i=0;i<c.length;i++){
15+
res=s.charAt(j);
16+
if(c[i]!='0' && c[i]==res){
17+
count++;
18+
c[i]='0';
19+
}
20+
}
21+
if(count!=0){
22+
System.out.println(res+" - "+count);
23+
count=0;
24+
}
25+
else
26+
count=0;
27+
}
28+
}
29+
}
30+

String/CountVowel.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import java.util.Scanner;
2+
3+
public class CountVowel{
4+
public static String[] split(String s){
5+
int c = 0;
6+
for (int i=0;i<s.length();i++){
7+
if(s.charAt(i)==' '){
8+
c+=1;
9+
}
10+
}
11+
String[] st=new String[c+1];
12+
String t="";
13+
int j=0;
14+
for (int i=0;i<s.length();i++){
15+
if(s.charAt(i)!=' '){
16+
t += s.charAt(i);
17+
}else{
18+
st[j++] = t;
19+
t = "";
20+
}
21+
}
22+
st[j]=t;
23+
return st;
24+
}
25+
public static void main(String[] arg){
26+
Scanner sc = new Scanner(System.in);
27+
System.out.println("Enter the String: ");
28+
String s = sc.nextLine();
29+
String vow="aeiou";
30+
String[] words=split(s);
31+
String t="";
32+
int c=0;
33+
for(int i=0;i<words.length;i++){
34+
t+=words[i];
35+
for(int k=0;k<t.length();k++){
36+
for(int j=0;j<vow.length();j++){
37+
if(t.charAt(k)==vow.charAt(j)){
38+
c++;
39+
}
40+
}
41+
}
42+
System.out.println(t+"="+c);
43+
t=""; c=0;
44+
}
45+
}
46+
}
47+
48+

String/SubString.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
3+
public class SubString{
4+
public static void main(String... arg){
5+
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter the String: ");
8+
String s=sc.nextLine();
9+
sc.close();
10+
for(int k=0;k<s.length();k++){
11+
for(int i=k;i<s.length();i++){
12+
for(int j=k; j<=i;j++){
13+
System.out.print(s.charAt(j));
14+
}
15+
System.out.println();
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)
0