Java - Programming Language
This course covers the basics of programming in Java. Work your way through the videos and we'll teach you everything you need to know to start your programming journey!

Math

Lesson 8
Author : Mike Dane
Last Updated : October, 2017


Code

CopySystem.out.println( 2 * 3 );       // Basic Arithmetic: +, -, /, *
System.out.println( 10 % 3 );      // Modulus Op. : returns remainder of 10/3
System.out.println( 1 + 2 * 3 );   // order of operations
System.out.println(10 / 3.0);      // int's and doubles


int num = 10;
num += 100; // +=, -=, /=, *=
System.out.println(num);

num++;
System.out.println(num);

// Math class has useful math methods
System.out.println( Math.pow(2, 3) );
System.out.println( Math.sqrt(144) );
System.out.println( Math.round(2.7) );