Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- String str = "Hello WorlD";
- int choice = 1;
- char[] arr= str.toCharArray();
- while (choice != 4) {
- System.out.println("1. Uppercase");
- System.out.println("2. Lowercase");
- System.out.println("3. ToggleCase");
- System.out.println("4. Exit");
- System.out.print("\nEnter your choice : ");
- choice = sc.nextInt();
- if (choice == 1) {
- System.out.println("Upper : " + str.toUpperCase());
- }
- else if (choice == 2) {
- System.out.println("Lower : " + str.toLowerCase());
- }
- else if (choice == 3) {
- System.out.print("Toggle : ");
- for (char ch : arr) {
- if(Character.isUpperCase(ch)){
- ch= Character.toLowerCase(ch);
- }
- else if(Character.isLowerCase(ch)){
- ch= Character.toUpperCase(ch);
- }
- System.out.print(ch);
- }
- }
- else if (choice == 4) {
- System.out.println("Program Terminated");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement