import java.util.Scanner;
public class StringCaseConverter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
int length = inputString.length();
System.out.println("Length of the string: " + length);
System.out.println("Choose an operation:");
System.out.println("1. Convert to Uppercase");
System.out.println("2. Convert to Lowercase");
int choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("Uppercase: " + inputString.toUpperCase());
break;
case 2:
System.out.println("Lowercase: " + inputString.toLowerCase());
break;
default:
System.out.println("Invalid choice");
}
}
}
No comments:
Post a Comment