grodek118

String Manipulator

Aug 31st, 2022
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. Scanner keyboard = new Scanner(System.in);
  2.  
  3.         String city;
  4.         char letter;
  5.         int stringSize;
  6.  
  7.         System.out.println("Please enter your favourite city: ");
  8.         city = keyboard.nextLine();
  9.         stringSize = city.length();
  10.         letter = city.charAt(0);
  11.  
  12.         System.out.println("Number of characters in the name: " + stringSize);
  13.         System.out.println("In upper case: " + city.toUpperCase());
  14.         System.out.println("In lower case: " + city.toLowerCase());
  15.         System.out.println("Firs character in the name: " + letter);
Advertisement
Add Comment
Please, Sign In to add comment