Advertisement
HcNguyen111

PT: Chap 2 - Programming Challenges Q12

Mar 4th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.    
  3. public class HelloWorld
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         String favCity;
  8.            
  9.         Scanner keyboard = new Scanner(System.in);
  10.  
  11.         System.out.print("What is your favourite City? ");
  12.         favCity = keyboard.nextLine();
  13.        
  14.         keyboard.close();
  15.        
  16.         String upperCase = favCity.toUpperCase();
  17.         String lowerCase = favCity.toLowerCase();
  18.         int length = favCity.length();
  19.         char firstChar = favCity.charAt(0);
  20.  
  21.         System.out.println(length);
  22.         System.out.println(upperCase);
  23.         System.out.println(lowerCase);
  24.         System.out.println(firstChar);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement