write a menu driven program in java 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
Share
write a menu driven program in java 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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
import java.util.*;
public class pattern
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("1. First five upper case letters");
System.out.println("2. Last five lower case letters");
System.out.println("Enter your choice");
int ch = in.nextInt();
switch(ch)
{
case 1:
{
int a;
char b;
for(a=65;a<=69;a++)
{
b=(char)a;
System.out.print(b+" ");
}
}
break;
case 2:
{
int c;
char d;
for(c=118;c<=122;c++)
{
d=(char)c;
System.out.print(d+" ");
}
}
break;
default:
System.out.println("Wrong choice");
break;
}
}
}
Explanation: