forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoubloon.java
More file actions
31 lines (27 loc) · 836 Bytes
/
Copy pathDoubloon.java
File metadata and controls
31 lines (27 loc) · 836 Bytes
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
import java.util.Scanner;
public class Doubloon {
public static void main(String[] args) {
String word;
int[] letterHistogram;
Scanner input = new Scanner(System.in);
System.out.print("Please enter a word: ");
word = input.nextLine();
letterHistogram = Ex2.letterHist(word);
isDoubloon(word);
}
public static void isDoubloon(int[] letterHistogram){
String uniformWord = word.toLowerCase();
int i = 0;
boolean result = false;
do {
if (letterHistogram[i] == letterHistogram[i + 1]) {
result = true;
i++;
} else {
result = false;
break;
}
} while (i < (letterHistogram.length - 1));
System.out.println(result);
}
}