-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring7.java
More file actions
97 lines (63 loc) · 2.25 KB
/
string7.java
File metadata and controls
97 lines (63 loc) · 2.25 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package demo;
import java.util.Scanner;
public class string7 {
public static void main(String[] args) {
String str, rev = "";
Scanner sc = new Scanner(System.in);
System.out.println("Enter String");
str = sc.nextLine();
int length = str.length();
for ( int i = length - 1; i >= 0; i-- )
rev = rev + str.charAt(i);
if (str.equals(rev))
System.out.println(str+" is a palindrome");
else
System.out.println(str+" is not a palindrome");
int countA=0,countE=0,countI=0,countO=0,countU=0;
if (rev.contains("a")||rev.contains("e")||rev.contains("i")||rev.contains("o")||rev.contains("u"))
{
//System.out.println("it contains vowel");
for(int i = 0;i<rev.length();i++) {
if (rev.charAt(i)== 'a') {
countA++;
break;
}}
for(int i = 0;i<rev.length();i++) {
if (rev.charAt(i)== 'e') {
countE++;
break;
}
}
for(int i = 0;i<rev.length();i++) {
if (rev.charAt(i)== 'i') {
countI++;
break;
}
}
for(int i = 0;i<rev.length();i++) {
if (rev.charAt(i)== 'o') {
countO++;
break;
}
}
for(int i = 0;i<rev.length();i++) {
if (rev.charAt(i)== 'u') {
countU++;
break;
}
}
}
else System.out.print("String does not contain any vowels");
if (countA>=1 && countE>=1) {System.out.print("True");}
else if (countA>=1 && countI>=1) {System.out.print("True");}
else if (countA>=1 && countO>=1) {System.out.print("True");}
else if (countA>=1 && countU>=1) {System.out.print("True");}
else if (countE>=1 && countI>=1) {System.out.print("True");}
else if (countE>=1 && countO>=1) {System.out.print("True");}
else if (countE>=1 && countU>=1) {System.out.print("True");}
else if (countI>=1 && countO>=1) {System.out.print("True");}
else if (countI>=1 && countU>=1) {System.out.print("True");}
else if (countO>=1 && countU>=1) {System.out.print("True");}
else System.out.print("False");
}
}