Skip to content

Commit e416be6

Browse files
author
Oskar Enmalm
authored
Create Abecedarian.java
1 parent 0aee19d commit e416be6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Misc/Abecedarian.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//Oskar Enmalm 29/9/17
2+
//An Abecadrian is a word where each letter is in alphabetical order
3+
4+
class Abecedarian{
5+
6+
public static boolean isAbecedarian(String s){
7+
int index = s.length() - 1;
8+
9+
for(int i =0; i <index; i++){
10+
11+
if(s.charAt(i)<=s.charAt(i + 1)){} //Need to check if each letter for the whole word is less than the one before it
12+
13+
else{
14+
System.out.println("That is not abecedarian");
15+
return false;
16+
}
17+
18+
}
19+
System.out.println("Wow, that number is abecedarian");
20+
return true;
21+
}

0 commit comments

Comments
 (0)