-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay-03-Java-Q19
More file actions
53 lines (39 loc) · 1.47 KB
/
Copy pathDay-03-Java-Q19
File metadata and controls
53 lines (39 loc) · 1.47 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
42
43
44
45
46
47
48
49
50
51
52
53
/*Maya wants to know how the Numbers are converted to string in the program.could you please help her to implements the program.
Input Format
input consists of one integer
Constraints
Given N is greater than 0 and lesser than 9
Output Format
print the number into string type.
Sample Input 0
0
Sample Output 0
Integer is 0 and String is Zero
Sample Input 1
2
Sample Output 1
Integer is 2 and String is Two
Sample Input 2
10
Sample Output 2
Invalid Input*/
#Answer
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n == 0) System.out.println("Integer is 0 and String is Zero");
else if(n == 1) System.out.println("Integer is 1 and String is One");
else if(n == 2) System.out.println("Integer is 2 and String is Two");
else if(n == 3) System.out.println("Integer is 3 and String is Three");
else if(n == 4) System.out.println("Integer is 4 and String is Four");
else if(n == 5) System.out.println("Integer is 5 and String is Five");
else if(n == 6) System.out.println("Integer is 6 and String is Six");
else if(n == 7) System.out.println("Integer is 7 and String is Seven");
else if(n == 8) System.out.println("Integer is 8 and String is Eight");
else if(n == 9) System.out.println("Integer is 9 and String is Nine");
else System.out.println("Invalid Input");
sc.close();
}
}