import java.util.Scanner;

public class ScannerExample {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    
    String fromKeyboard;
    System.out.print("Enter a character: ");
    fromKeyboard = in.next();
    System.out.println("fromKeyboard is " + fromKeyboard);
    
    char ch;
    int i;
    double d;
    ch = fromKeyboard.charAt(0);  // gets first char of string
    System.out.println("ch is " + ch);
    i = ch;
    System.out.println("i is " + i);
    d = i;
    System.out.println("d is " + d);
    
    System.out.print("Enter a number: ");
    d = in.nextDouble();
    System.out.println("d is now " + d);
    i = (int) d;     // (int) is a cast
    System.out.println("i is now " + i);
    ch = (char) i;   // (char) is a cast
    System.out.println("ch is now " + ch);
    
    System.out.print("Enter a temp in F: ");
    d = in.nextDouble();
    System.out.println("F is " + d);
    // use (double) cast to avoid integer division
    d = (d - 32) * ((double) 5 / (double) 9);
    System.out.println("C is " + d);
  }
}