What is pair programing?    

  It's more fun than it sounds: two programmers at one computer.

One drives; the other navigates.    

  Switching roles fluidly, they constantly communicate.

Together, they accomplish better work more quickly than either could alone.    

  The driver types.

She focuses on tactics: writing clean code that compiles and runs.

  The navigator focuses on strategy: how the code fits into the overall design,
                                     which tests will drive the code forward, and
                                     which refactorings will improve the entire codebase.

Pairs self-organize by selecting partners who can best help with the current task.    

  They switch every few hours to share perspectives and knowledge.

As explained in The Art of Agile Development (see chapter 5, p. 71)?

  Are we working in pairs in this lab?

From now on, you can, if you want, so: yes.    

  How do we turn things in?

State in your assignment submission for each problem:
(a) who was your partner
(b) what problem you were the driver for
(c) what problem you were the navigator for
Also indicate the percentage of entire work you feel responsible for.

  And indicate how much of the work is due to your partner, also as a percentage, overall.    

This last assessement is subjective so please explain it briefly.

  It is also confidential, so you do not need to share it with your partner.    

Alright, what do we do next?

Let's look at Lab 02 and Homework 01! 

import java.util.*; 

public class Four {
  public static void main(String[] args) {
    Scanner a; 
    // https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html
    a = new Scanner(System.in); // scans the keyboard
    // System.out.println( a );
    System.out.print("How much fuel: " );
    double fuel = a.nextDouble(); 
    System.out.print("What's the mileage: ");
    int mpg = a.nextInt(); 
    System.out.print("How far do you want to go (miles): "); 
    double miles = a.nextDouble(); 
    
    if ( miles <= mpg * fuel ) {
      System.out.println( "You will make it." );  
    } else {
      System.out.println( "You will not make it." );        
    }
    
  }
}

Here's how it runs: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Four
How much fuel:  3
What's the mileage:  10
How far do you want to go (miles):  29
You will make it.
> run Four
How much fuel:  3
What's the mileage:  10
How far do you want to go (miles):  31
You will not make it.


How do you do this without an if? 

class LabTwo {
  public static void main(String[] args) {
    int n = 0; // if n is 1 "You will not make it."
               // if n is 0 "You will make it." 
    System.out.println( 
       "You will " + 
       " not ".substring(5 - 4 * n) +      
       "make it."                 
                       );
    // this is step 1. now convert the test into 0 or 1.
  }
}

Here's an experiment:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> String a = "automaton";
//            012345678
> a
"automaton"
> a.substring(3, 5)
"om"
> a.substring(2)
"tomaton"
> a.substring(2, 6)
"toma"
> a.substring(2, 7)
"tomat"
> a.substring(2, 8)
"tomato"


So we need something like this: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> String word = " not "
> word.substring(0, 1)
" "
> word.substring(0, 5)
" not "
> "You will" + word.substring(0, 1) + "make it."
"You will make it."
> "You will" + word.substring(0, 5) + "make it."
"You will not make it."


class Seven {
  public static void main(String[] args) {
    
    int x = 6, y = 7; 
    
    if (x > 3) {
      if (x <= 5)
        y = 1;
      else if (x != 6)
        y = 2;
    } else
      y = 3;   
    
    
    System.out.println( y ); // y unchanged 
    
  }  
}



    // Let's simplify now (x < 5) && (x < 25) if x is an int variable.

    // Answer: x < 5 this seems to be the answer (see below) 
 
    // Another answer: x < 25 that seems to not be the answer  

    //   x                             5             25 
    //  ----------------------------------------------------------------
    //   x < 5               T T T T   F    F F F    F    F F F F 
    //  ----------------------------------------------------------------
    //   x < 25              T T T T   T    T T T    F    F F F F 
    //  ----------------------------------------------------------------
    //   x < 5 && x < 25     T T T T   F    F F F    F    F F F F 


Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> int i = 5
> i
5
> i++
5
> i
6
> ++i
7
> i
7
> i++
7
> i
8
> ++i
9
> i
9
>


class Eight {
  public static void main(String[] args) {
    int j = 3; 
    // j is now 3
    int b = ++j + j++;
    //  4 and j becomes 4
    //        4 and j becomes 5
    // so j becomes 4 + 4 which is 8
    System.out.println( b ); // 8
    System.out.println( j ); // 5
  }
}


http://www.cs.indiana.edu/classes/c211/sum2014/labTen.html