Mr. Truncale - Robert E. Lee High School
  • Home
  • Digital Media
    • HTML
  • Video Game Design
  • Comp. Programming I
  • Comp. Programming II
  • AP Computer Science
  • 3D Printing
  • Teacher Resources
  • Contact Me

Java - Math Notes


// Common math operations + - * / %
int a = 1234;
int b = 7;
int answer = a/b;
int remainder = a%b;
System.out.println(answer +" with a remainder of " + remainder);
// NOTE: PEMDAS

// Increment and de-increment operators
double c = 0;
c = c+1;
c++;
System.out.println(c);
// Shortcut operators += -=
c += 10;
System.out.println(c);
// When you divide to integers you will get an integer result

// Methods of the math class
// abs pow sqrt ceil floor round min max PI random
// log sin cos tan asin acos atan toDegrees toRadians
// NOTE: sin cos tan gives answers in radians
System.out.println( Math.abs(-10) );
System.out.println( Math.pow(12,3) );
System.out.println( Math.sqrt(99) );
System.out.println( Math.ceil(123.00001) );
System.out.println( Math.floor(123.9999) );
System.out.println( Math.PI );

Videos


lesson5_part1.swf
File Size: 5229 kb
File Type: swf
Download File

lesson5_part2.swf
File Size: 6176 kb
File Type: swf
Download File

lesson6_part1.swf
File Size: 7708 kb
File Type: swf
Download File

lesson6_part2.swf
File Size: 5456 kb
File Type: swf
Download File

Powered by Create your own unique website with customizable templates.