Computer Applications

Write a menu driven program to display
(i) first five upper case letters
(ii) last five lower case letters as per the user's choice.
Enter '1' to display upper case letters and enter '2' to display lower case letters.

Java

Java Library Classes

47 Likes

Answer

import java.util.Scanner;

public class KboatMenuUpLowCase
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter '1' to display upper case letters");
        System.out.println("Enter '2' to display lower case letters");
        
        System.out.print("Enter your choice: ");
        int ch = in.nextInt();
        
        switch (ch) {
            case 1:
            for (int i = 65; i <= 69; i++)
                System.out.println((char)i);
            break;
            
            case 2:
            for (int i = 118; i <= 122; i++)
                System.out.println((char)i);
            break;
            
            default:
            break;
        }
    }
}

Variable Description Table

Program Explanation

Output

Answered By

15 Likes


Related Questions