-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumberToWord.java
More file actions
34 lines (30 loc) · 816 Bytes
/
Copy pathnumberToWord.java
File metadata and controls
34 lines (30 loc) · 816 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
32
33
34
import java.util.Scanner;
public class numberToWord {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number (1-5): ");
int number = sc.nextInt();
String word;
switch (number) {
case 1:
word = "One";
break;
case 2:
word = "Two";
break;
case 3:
word = "Three";
break;
case 4:
word = "Four";
break;
case 5:
word = "Five";
break;
default:
word = "Invalid number";
}
System.out.println("The number in words is: " + word);
sc.close();
}
}