Access over 35 million academic & study documents

Lectures 1 notes

Content type
User Generated
Rating
Showing Page:
1/48

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/48

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/48

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 48 pages?
Access Now
Unformatted Attachment Preview
6.092: Intro to Java 2: More types, Methods, Conditionals Outline • • • • Lecture 1 Review More types Methods Conditionals Types Kinds of values that can be stored and manipulated. boolean: Truth value (true or false). int: Integer (0, 1, -47). double: Real number (3.14, 1.0, -2.1). String: Text (“hello”, “example”). Variables Named location that stores a value Example: String a = “a”; String b = “letter b”; a = “letter a”; String c = a + “ and “ + b; Operators Symbols that perform simple computations Assignment: = Addition: + Subtraction: ­ Multiplication: * Division: / class GravityCalculator { public static void main(String[] args) { double gravity = -9.81; double initialVelocity = 0.0; double fallingTime = 10.0; double initialPosition = 0.0; double finalPosition = .5 * gravity * fallingTime * fallingTime; finalPosition = finalPosition + initialVelocity * fallingTime; finalPosition = finalPosition + initialPosition; System.out.println("An object's position after " + fallingTime + " seconds is " + finalPosition + “ m."); } } finalPosition = finalPosition + initialVelocity * fallingTime; finalPosition = finalPosition + initialPosition; OR finalPosition += initialVelocity * fallingTime; finalPosition += initialPosition; Questions from last lecture? Outline • • • • Lecture 1 Review More types Methods Conditionals Division Division (“/”) operates differently on integers and on doubles! Example: double ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Awesome! Made my life easier.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4