/* CPE 315 Program to show that (x+y) + z != x + (y+z) */ import java.io.*; public class associative { public static void main (String args[]) { float a = 1.111f; float b = 2.222f; float c = 3.333f; float d = (a + b) + c; float e = a + (b + c); System.out.println ("d = " + d); System.out.println ("e = " + e); if (d == e) System.out.println ("floating point addition is associative"); else System.out.println ("floating point can cause arithmetic problems"); } } /* Output d = 6.6659994 e = 6.666 floating point causes arithmetic problems */