-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyChar.java
57 lines (43 loc) · 1004 Bytes
/
MyChar.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
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
package com.primitive;
public class MyChar {
char ch;
public MyChar(char ch) {
this.ch = ch;
}
public boolean IsVowel() {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I'
|| ch == 'O' || ch == 'U') {
return true;
} else {
return false;
}
}
public boolean IsNumber() {
if (ch >= 48 && ch <= 57) {// between '0' and '9'
return true;
} else {
return false;
}
}
public boolean IsAlphabet() {// between 'a' and 'z'
if(ch>=97 ||ch<=122) {
return true;
}
if (ch >= 65 || ch <= 90) {
return true;
} else {
return false;
}
}
public static void printLowerCaseAlphabets() { // methods containing static no need to create objects
for (char ch = 'a'; ch <= 'z'; ch++) {
System.out.println(ch);
}
}
public static void printUpperCaseAlphabets()
{
for (char ch = 'A'; ch <= 'Z'; ch++) {
System.out.println(ch);
}
}
}