Last active
October 31, 2018 02:17
-
-
Save ThanawatMas/ce25b8d6ad810338035aca1ccd3ff665 to your computer and use it in GitHub Desktop.
Different between divide by int, and divide by double
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DivideExample { | |
public static void main(String[] args) { | |
int a = 9; | |
int b = 2; | |
int c = 5; | |
double average1 = (a+b+c) / 3; | |
System.out.println("average1 of a+b+c = " + average1); | |
int x = 9; | |
int y = 2; | |
int z = 5; | |
double average2 = (x+y+z) / 3.0; | |
System.out.println("average2 of x+y+z = " + average2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment