You can use a string's Value property to determine the number of characters it stores.
Answer the following statement true (T) or false (F)
False
You might also like to view...
The conversion of a mouse movement or pressing a key or processing audio signals is performed by the ________ inside the computer
A) laser diode B) microprocessor C) sampling rate D) attenuation
For a given set s, which method returns True if item is in s, or False otherwise.
A. s.__contains__(item) B. s.__iter__(item) C. s = set() D. S1.__sub__(s2)
Which of the following allows you to choose alternative file formats when you save a file?
A. Save as type B. Save as format C. Save with extension D. Save as document
Write a new class TruncatedDollarFormat that is the same as the class DollarFormat from Listing 6.14, except that it truncates rather than rounds to obtain two digits after the decimal point. When truncating, all digits after the first two are discarded, so 1.229 becomes 1.22, not 1.23. Repeat Programming Project 3 in Chapter 4 using this new class.
This project may require a little trial and error to get the code right to truncate past the two digits of the cents and not lose the cents completely. Casting a double to an int will truncate, but it has to be done after the dollars.cents is multiplied by 100, and an explicit cast is required by the java compiler (unlike C or C++): ``` int allCents = amount * 100; ``` gives a compiler error since amount is type double. ``` int allCents = (int)amount * 100; ``` loses the cents part of amount because the cast operates on amount before multiplying by 100. Putting parentheses around the multiplication, however, makes it do the multiplication first: ``` int allCents = (int)(amount * 100); ``` so it does not lose the cents digits. The only other “tricky” part is using the write() method in TruncatedDollars along with System.out.println() and System.out.print() to display money values interspersed with text in sentences.