Java Reference
In-Depth Information
sent.append(inputWords[i]);
sent.append(" ");
}
System.out.println (sent.toString());
10. Compile and run this class. The output should look like this:
...
These are words in a sentence
11. Now it's time to experiment with the BigDecimal and the BigInteger
classes. Add these bolded Java statements to the beginning of your Hello-
World source:
import java.text.*;
import java.math.*;
import java.util.*;
//
//
// HelloWorld Application
//
//
12. Add these Java statements to the end of the previous statement (before the
last two curly braces):
// Experiment with BigNumbers
// Construct some numbers to work with:
BigDecimal accountBalance1 = new BigDecimal ("12345.678");
BigDecimal accountBalance2 = new BigDecimal ("876.54321");
BigDecimal accountBalance3 = new BigDecimal ("1");
BigDecimal transactionAmount = new BigDecimal ("100.00");
// Add the transaction amount to the account balance.
accountBalance1 = accountBalance1.add (transactionAmount);
System.out.println ("accountBalance1 = " +
accountBalance1);
// Compute the discounted amount of the transaction, and place
// into a new
// variable with the same scale as the transactionAmount
// variable.
Search WWH ::




Custom Search