/** * This example demonstrates how to convert data types from one to another * @author Brad Rippe */ public class TestFormula { public static void main(String astring[]) { double d1 = 3.141592653589793; double radius = 2.22; System.out.println("Computing formula - 4/3 * pi * radius * radius * radius"); System.out.println("Computing formula - (double)4/3 * pi * radius * radius * radius"); double d3 = 4/3 * d1 * radius * radius * radius; double d4 = (double)4/3 * d1 * radius * radius * radius; System.out.println("Result 1: " + d3); System.out.println("Result 2: " + d4); System.out.println("Why aren't the two formulas equal?"); } }