teaching machines

CS 145 Lecture 3 – Variables, Types, and Named Operations

September 8, 2014 by . Filed under cs145, fall 2014, lectures.

Agenda

TODO

Program This

Code

Projectile.java

package lecture0908;

public class Projectile {
  public static void main(String[] args) {
    double t = 5;
    System.out.printf("(%f,%f),",
                      632 * t + 0.0,
                      20.0 + 1 * t - 4.9 * t * t);
    
    t = 10;
    System.out.printf("(%f,%f),",
                      632 * t + 0.0,
                      20.0 + 1 * t - 4.9 * t * t);

    t = 0.1;
    System.out.printf("(%f,%f)",
                      632 * t + 0.0,
                      20.0 + 1 * t - 4.9 * t * t);
  }
}

NamedOperations.java

package lecture0908;

public class NamedOperations {
  public static void main(String[] args) {
    System.out.println(Math.pow(26, 4));
    
    double score1 = 78.1;
    double score2 = 85.5;
    double worse = Math.min(score1, score2);
    double rounded = Math.floor(worse);
    System.out.println(rounded);
    System.out.println(Math.floor(Math.min(score1, score2)));
  }
}

Haiku

on the power of naming things:
Say “F U, Cancer!”
You can ‘cuz it has a name
What took Dad away?