/** * Author: Josiah Yoder et al. * User: yoder * Class: SE1011-011 * Date: 10/21/13 1:18 AM * Lesson: Week 7, Day 1 */ import java.text.DecimalFormat; import java.util.Scanner; public class Example011_8_2 { public static void main(String[] ignored) { // "static" constants // are class constants, // not instance constants // double x = c1.MY_CONSTANT; // How to use an instance constant double y = Complex011_8_2.MY_CONSTANT; // How to use a class constant // DecimalFormat // # -- a digit // 0 -- a digit, but prints even if it is zero. DecimalFormat myFormat = new DecimalFormat("####.00"); Scanner in = new Scanner(System.in); double d; do { System.out.println("Enter a number. 0 to exit."); d = in.nextDouble() ; System.out.println("You entered "+myFormat.format(d)); } while(d != 0); Complex011_8_2 c1 = new Complex011_8_2(3,4); Complex011_8_2 c2 = new Complex011_8_2(4,10); // a c1 = c1.add(c2); // b } }