front 1 Write a program that demonstrates the approximate nature of floating-point values by performing the following task:
| back 1 Scanner keyboard = new Scanner(System.in);
|
front 2 Write a program that demonstrates type casting of double values by performing the following tasks:
| back 2 Scanner keyboard = new Scanner(System.in);
|
front 3 Write a program that demonstrates the operator % by performing the following tasks:
| back 3 Scanner keyboard = new Scanner(System.in);
|
front 4 If u = 2, v = 3, w = 5, x = 7 and y = 11, what is the value of each of the following expressions, assuming int variables?
| back 4 (a)24
|
front 5 What changes to the ChangeMaker program in Listing 2.3 are necessary if it also accepts coins for one dollar and half a dollar? | back 5 (1)
|
front 6 If the int variable x contains 10, what will the following Java statements display?
| back 6 Test 1 60.0
|
front 7 Write some Java statements that use the String methods indexOf and substring to find the first word in a string. We define word to be a string of characters that does not include whitespace. For example, the first word of the string "Hello, my good friend!" is the string "Hello," and the second word is the string "my". | back 7 String sentence = "Hello, my good friend!";
|
front 8 Repeat the previous exercise, but find the second word in the string. | back 8 String sentence = "Hello, my good friend!";
|
front 9 What does the following Java statement display?
| back 9 It' Text\\
|
front 10 Write a single Java statement that will display the words one, two, and threee, each on its own line. | back 10 System.out.println("one\ntwo\nthree"); |
front 11 What does the Java code
| back 11 You get an InputMismatchException because "2istheinput" cannot be converted to an int.
|
front 12 Wht does the Java code
| back 12 a is B
|
front 13 Repeat the previous exercise, but change next to nextLine in the statement that assigns a value to b. | back 13 a is B
|
front 14 Many sports have constants embedded in their rules. For example, baseball has 9 innings, 3 outs per inning, 3 strikes in an out, and 4 balls per walk. We might encode the constants for a program involving baseball as follows:
| back 14 Basketball:
|
front 15 Repeat Exercise 18 in Chapter 1, but define and use named constants. | back 15 public static final int WIDTH = 120;
|
front 16 Define named constants you could use in Programming Project 8 in Chapter 1. | back 16 public static final int ARC_RADIUS_1 = 100;
|