Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
double dollar = 1.0;

double dime = 0.1;

int number = 7;

System.out.println ("A dollar less " + number + " dimes is $" +
		    (dollar - number*dime) );

...

Code Block
bgColor#ccccff
long dollar = 100;

long dime = 10;

int number = 7;

System.out.println ("A dollar less " + number + " dimes is " +
		    (dollar - number*dime) + " cents" );

...

Code Block
bgColor#ccccff
import java.math.BigDecimal;

// ...

BigDecimal dollar = new BigDecimal("1.0");

BigDecimal dime = new BigDecimal("0.1");

int number = 7;

System.out.println ("A dollar less " + number + " dimes is $" +
	(dollar.subtract( new BigDecimal(number).multiply(dime) )) );

...