CS 145 Lecture 3 – Variables, Types, and Named Operations
Agenda
- what ?s
- program this
- concatenation
- variables
- types
- declarations
- declassignments
- printf
- named operations in the
Math
class
TODO
- Start homework 1. Due before September 19.
Program This
- How can one determine the position of a ball launched into the air? What does one need to know?
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?
Say “F U, Cancer!”
You can ‘cuz it has a name
What took Dad away?