QUESTION:-
WRITE A PROGRAM IN JAVA TO CONVERT ANY INTEGER TO A LETTER IN THE RANGE OF 0 TO 27. TAKE AN INTEGER AND ACCEPT IT AS 'N' SUCH THAT IT FOLLOWS THIS CONDITION
0>N>27
DISPLAY THE CORRESPONDING LETTER OF THE ALPHABET
[FOR EG IF N=1 THEN DISPLAY 'A']
IT LOOKS LIKE A TRICK PROGRAM
STUDENT DIFFICULTY LEVEL= 5.5/10 AS RATED BY THE CANDIDATES
CONCEPTS REQUIRED= Typecasting, Library classes, character concept, core concept, ASCII value concept
SOLUTION
import java.util.*;
class Integer2Letter
{
void main()
{
Scanner ob=new Scanner(System.in);
int n;
System.out.println("Enter an Integer");
n=ob.nextInt();//INPUT IN INTEGER FORMAT
if(n>0 && n<27)//RANGE CHECK
{
char ch= (char)(n+64);//IF N=1 THAN 64+1=65 WHICH EQUAL TO THE ASCII VALUE OF 'A'
System.out.println("the corresponding letter is="+ch);
}
else
{
System.out.println("Please enter the correct range");
}
}
}