Use the interactions panel to clarify meaning of operators. 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> 1
1
> "a"
"a"
> 'a'
'a'
> true
true
> 1 < 2
true
> true && false
false
> true || false
true
> 1 != 2
true
> 1 == 2
false
> (1 + 1) == 2
true
> !(true || false)
false
> 2 / 3
0
> 2.0 / 3
0.6666666666666666
> (double) 3
3.0
> (double) ( 2 / 3 )
0.0
> "1" + 1
"11"
> '1' + 1
50
> '1' + 0
49
> (char) 49 
'1'
> '1' - '2'
-1
> 'a' - 'b'
-1
> 'a' + 0
97
> 'A' + 0
65
> '0' + 0
48
> ' ' + 0
32
> '{' + 0
123
> "how" + "ever"
"however"
> String a = "automaton"; 
> a.substring(2, 8)
"tomato"
>

Now time to look at our problems. 


class Example {
  public static void main(String[] args) {
    Scanner speckles = new Scanner(System.in); 
    String line = speckles.nextLine(); 
    double a = speckles.nextDouble(); 
    int b = speckles.nextInt(); 
    String c, d; 
    c = speckles.next(); 
    d = speckles.next();     
    System.out.println(line); 
    System.out.println(a); 
    System.out.println(b);
    System.out.println(c); 
    System.out.println(d); 
    
  }
}

This compiled and run produces:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Example
 [I am writing all of this on a line 6 54.2 pi 3.141592 and so on.]
 [3.4 123 house]
 [helicopter]
I am writing all of this on a line 6 54.2 pi 3.141592 and so on.
3.4
123
house
helicopter


Attendance for the day: 

   Let t1 and t2 be hours, that is, integers in the interval [0, 24).

   Let's develop a formula together such that 

      if t1 is  9 and t2 is 17 the program returns  8 (hours)

      if t1 is 17 and t2 is  9 the program returns 16 (hours). 

   What is a good formula? 

   Let's write this program:

class LabTwo {
  public static void main(String[] args) {
    String t1 = args[0]; 
    String t2 = args[1]; 
    System.out.println( t1 + " " + t2 ); 
  }
}

   Compile and run it:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java LabTwo 4 5
4 5
> java LabTwo 4 5 6 7 8 9
4 5
> java LabTwo 4 
java.lang.ArrayIndexOutOfBoundsException: 1
    at LabTwo.main(LabTwo.java:4)


   Here's half of the problem solved:

class LabTwo {
  public static void main(String[] args) {
    int t1 = Integer.parseInt( args[0] ); 
    int t2 = Integer.parseInt( args[1] ); 
    int result = t2 - t1; 
    System.out.println( result + " hours.");
  }
}

This works as follows: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java LabTwo 15 21
6 hours.
> java LabTwo 9 13
4 hours.


We then come up with:

class LabTwo {
  public static void main(String[] args) {
    int t1 = Integer.parseInt( args[0] ); 
    int t2 = Integer.parseInt( args[1] ); 
    int result = (t2 + 24 - t1) % 24; 
              // t2      - t1; 
    System.out.println( result + " hours.");
  }
}

Here it is in action: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java LabTwo 11 9
22 hours.
> java LabTwo 9 11
2 hours.


Please submit this program before the end of the lab for attendance.

Submit the actual assignment by tomorrow 5pm (midnight). 

--