-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path11.1 ABCD_Game.java
56 lines (42 loc) · 1.43 KB
/
11.1 ABCD_Game.java
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
54
55
56
/*
Peter is teaching ABCD.. to his younger brother through a game. The rules of the game include peter speaking 2 characters, and expecting his brother to speak all the alphabets in between based on the following conditions.
The two characters should be alphabets, in either case.
First alphabet should be smaller.
In all other cases ERROR should be displayed.
Input Format
two alphabets as input
Constraints
The two characters should be alphabets, in either case.
First alphabet should be smaller.
In all other cases ERROR should be displayed.
Output Format
Aplhabets in between or ERROR.
Sample Input 0
H X
Sample Output 0
H I J K L M N O P Q R S T U V W X
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
//declaring input char
char a1 = sc.next().charAt(0);
char a2 = sc.next().charAt(0);
//validating given constraint
if(((a1>='A' && a1 <='Z') || (a1>='a' && a1<='z'))&&((a2 >='A' && a2 <='Z') || (a2>='a' && a2<='z')))
{
//and solution
for(char i=a1 ; i<=a2 ; i++)
{
System.out.print(i+" ");
}
}
else
{
System.out.print("ERROR");
}
}
}