write a menu driven program to display i)First 5 upper case letters ii)Last 5 lower case letters as per the user's choice Enter 1 to display upper case letters and 2 to display lower case letters.
Answers
Answered by
0
// To display uppercase or lowercase as per user's choice
import java.util.*;
class choice
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i = 0;
String s;
System.out.println("Enter a word having ten letters");
s = sc.nextLine();
System.out.println("Enter 1 for uppercase letters or 2 for lowercase letters");
i = sc.nextInt();
if (i==1)
System.out.println(s.substring(0,5).toUpperCase());
else if (i==2)
System.out.println(s.substring(5).toLowerCase());
else if (i>2)
System.out.println("Invalid");
}
}
Similar questions