Advertisements
Advertisements
प्रश्न
Using switch case statement, write a menu driven program to perform the following tasks:
- To generate and print the letters from A to Z along with their Unicode.
Letters Unicode
A 65
B 66
.......... .........
.......... .........
Z 90 - To generate and print the letters from z to a along with their Unicode.
Letters Unicode
z 122
y 121
.......... .........
.......... .........
a 97
थोडक्यात उत्तर
उत्तर
import java.util.Scanner;
public class Q11
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.println("Enter 1 for A to Z with unicode");
System.out.println("Enter 2 for z to a with unicode");
System.out.print("Enter your choice: ");
int ch = in.nextInt();
switch (ch) {
case 1:
System.out.println("Letters" + "\t" + "Unicode");
for(int i = 65; i <= 90; i++)
System.out.println((char)i + "\t" + i);
break;
case 2:
System.out.println("Letters" + "\t" + "Unicode");
for (int i = 122; i >= 97; i--)
System.out.println((char)i + "\t" + i);
break;
default:
System.out.println("Incorrect Choice");
}
}
}
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: Library Classes - EXERCISES [पृष्ठ १८०]