KnowledgeBoat Logo

Computer Applications

Using switch case statement, write a menu driven program to perform the following tasks:
(a) To generate and print the letters from A to Z along with their Unicode.
Letters  Unicode
A           65
B           66
…..          ……..
…..          ……..
Z           90

(b) To generate and print the letters from z to a along with their Unicode.
Letters  Unicode
z           122
y           121
…..          ……..
…..          ……..
a           97

Java

Java Library Classes

17 Likes

Answer

import java.util.Scanner;

public class KboatLettersNUnicode
{
    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");
        }
    }
}

Variable Description Table

Program Explanation

Output

BlueJ output of Using switch case statement, write a menu driven program to perform the following tasks: (a) To generate and print the letters from A to Z along with their Unicode. Letters Unicode A 65 B 66 ….. …….. ….. …….. Z 90 (b) To generate and print the letters from z to a along with their Unicode. Letters Unicode z 122 y 121 ….. …….. ….. …….. a 97BlueJ output of Using switch case statement, write a menu driven program to perform the following tasks: (a) To generate and print the letters from A to Z along with their Unicode. Letters Unicode A 65 B 66 ….. …….. ….. …….. Z 90 (b) To generate and print the letters from z to a along with their Unicode. Letters Unicode z 122 y 121 ….. …….. ….. …….. a 97

Answered By

8 Likes


Related Questions