front 1 Write a fragment of code that will read words from the keyboard until the word done is entered. For each word except done, report whether its first character is equal to its last character. For the required loop, use a
 back 1 a)

front 2 Develop an algorithm for computing the monthbymonth balance in your savings account. You can make one transactiona deposit or a withdrawaleach month. Interest is added to the account at the beginning of each month. The monthly interest rate is the yearly percentage rate divided by 12.  back 2 double balance = 0.0,

front 3 Develop an algorithm for a simple game of guessing at a secret fivedigit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 53840, and the user guesses 83241, the digits 3 and 4 are in the correct position. Thus, the program should respond with 2 and 7. Allow the user to guess a fixed number of times.  back 3 String code = "37823";

front 4 Write a fragment of code that will compute the sum of the first n positive odd integers. For example, if n is 5, you should compute 1 + 3 + 5 + 7 + 9.  back 4 int n = 5,

front 5 Convert the following code so that it uses nested while statements instead of for statements:
 back 5 int s = 0;

front 6 Write a for statement to compute the sum 1 + 2² + 3² + 4² + 5² + ... + n².  back 6 int n = 20,

front 7 (Optional) Repeat the previous question, but use the comma operator and omit the for statement’s body.  back 7 int n = 20,

front 8 Write a loop that will count the number of blank characters in a given string.  back 8 String word = "hello w o r l d";

front 9 Write a loop that will create a new string that is the reverse of a given string.  back 9 String word = "0123456789",

front 10 Write a program that will compute statistics for eight coin tosses. The user will enter either an h for heads or a t for tails for the eight tosses. The program will then display the total number and percentages of heads and tails. Use the increment operator to count each h and t that is entered. For example, a possible sample dialogue between the program and the user might be
 back 10 Scanner keyboard = new Scanner(System.in);

front 11 Suppose we attend a party. To be sociable, we will shake hands with everyone else. Write a fragment of code using a for statement that will compute the total number of handshakes that occur. (Hint: Upon arrival, each person shakes hands with everyone that is already there. Use the loop to find the total number of handshakes as each person arrives.)  back 11 int numOfPeople = 5,

front 12 Define an enumeration for each of the months in the year. Use a foreach statement to display each month.  back 12 enum Month

front 13 Write a fragment of code that computes the final score of a baseball game. Use a loop to read the number of runs scored by both teams during each of nine innings. Display the final score afterwards.  back 13 Scanner keyboard = new Scanner(System.in);

front 14 Suppose that you work for a beverage company. The company wants to know the optimal cost for a cylindrical container that holds a specified volume. Write a fragment of code that uses an askbeforeiterating loop. During each iteration of the loop, your code will ask the user to enter the volume and the radius of the cylinder. Compute and display the height and cost of the container. Use the following formulas, where V is the volume, r is the radius, h is the height, and C is the cost.
 back 14 Scanner keyboard = new Scanner(System.in);

front 15 Suppose that we want to compute the geometric mean of a list of positive values. To compute the geometric mean of k values, multiply them all together and then compute the kth root of the value. For example, the geometric mean of 2, 5, and 7 is ³√2x5x7. Use a loop with a sentinel value to allow a user to enter an arbitrary number of values. Compute and display the geometric mean of all the values, excluding the sentinel. (Hint: Math.pow(x, 1.0/k) will compute the kth root of x.)  back 15 Scanner keyboard = new Scanner(System.in);

front 16 Image a program that compresses files by 80 percent and stores them on storage media. Before the compressed file is stored, it must be divided into blocks of 512 bytes each. Develop an algorithm for this program that first reads the number of blocks available on the storage media. Then, in a loop, read the uncompressed size of a file and determine whether the compressed file will fit in the space left on the storage media. If so, the program should compress and save the file. It continues until it encounters a file that will exceed the available space on the media.
 back 16 Read the number of block available and store in blocks

front 17 Create an applet that draws a pattern of circles whose centers are evenly spaced along a horizontal line. Use six constants to control the pattern: the number of circles to draw, the diameter of the first circle, the x and y coordinates of the center of the first circle, the distance between adjacent centers, and the change in the diameter of each subsequent circle.  back 17 import java.applet.*;

front 18 What does the following fragment of code display? What do you think the programmer intended the code to do, and how would you fix it?
 back 18 Display:

front 19 What does the following fragment of code display? What do you think the programmer intended the code to do, and how would you fix it?
 back 19 Display:
