-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDigits.java
More file actions
41 lines (37 loc) · 1.13 KB
/
Copy pathDigits.java
File metadata and controls
41 lines (37 loc) · 1.13 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
/**
* This class output a digit in verbal form.
*/
public class Digits {
// Array of digit's verbal form.
private static String[] digitArray = {
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
};
/**
* Method make digit in verbal form.
* @param digit - Digit for translate.
* @return Answer with digit in digital and verbal forms.
*/
public static void digitToString(int digit){
try{
System.out.println("Your digit " + digit + " is " + digitArray[digit]);
}
catch(IndexOutOfBoundsException e){
System.out.println("Your input is not a simple digit. Try use (0,...,9).");
}
}
public static void main(String argv[]){
// right use
digitToString(5);
//wrong use
digitToString(4566);
}
}