1 Introduction 2 Fundamental Data Types 3 Decisions 4 Loops 5 Methods 6 Arrays And Array Lists 7 Input/output And Exception Handling 8 Objects And Classes 9 Inheritance And Interfaces 10 Graphical User Interfaces 11 Advanced User Interfaces 12 Object-oriented Design 13 Recursion 14 Sorting And Searching 15 The Java Collections Framework 16 Basic Data Structures 17 Tree Structures 18 Generic Classes 19 Stream Processing 20 Advanced Input/output 21 Multithreading (web Only) 22 Internet Networking (web Only) 23 Relational Databases (web Only) 24 Xml (web Only) 25 Web Applications (web Only) expand_more
4.1 The While Loop 4.2 Problem Solving Hand-tracing 4.3 The For Loop 4.4 The Do Loop 4.5 Application Processing Sentinel Values 4.6 Problem Solving Storyboards 4.7 Common Loop Algorithms 4.8 Nested Loops 4.9 Problem Solving Solve A Simpler Problem First 4.10 Application Random Numbers And Simulations Chapter Questions expand_more
Problem 1RE: Given the variables String stars = ""; String stripes = =====; what do these loops print? a. int i =... Problem 2RE: What do these loops print? a. int i = 0; int j = 10; while (i j) { System.out.println(i + " " + j);... Problem 3RE: What do these code snippets print? a. int result = 0; for (int i = 1; i = 10; i++) { result = result... Problem 4RE: Write awhile loop that prints a. All squares less than n. For example, if n is 100, print 0 1 4 9 16... Problem 5RE: Write a loop that computes a. The sum of all even numbers between 2 and 100 (inclusive). b. The sum... Problem 6RE: Provide trace tables for these loops. a. int i = 0; int j = 10; int n = 0; while (i j) { i++; j;... Problem 7RE: What do these loops print? a. for (int i = 1; i 10; i++) { System.out.print(i + " "); } b. for (int... Problem 8RE: What is an infinite loop? On your computer, how can you terminate a program that executes an... Problem 9RE: Write a program trace for the pseudocode in Exercise E4.6, assuming the input values are 4 7-2-5 0. Problem 10RE: What is an off-by-one error? Give an example from your own programming experience. Problem 11RE: What is a sentinel value? Give a simple rule when it is appropriate to use a numeric sentinel value. Problem 12RE: Which loop statements does Java support? Give simple rules for when to use each loop type. Problem 13RE: How many iterations do the following loops carry out? Assume that i is not changed in the loop body... Problem 14RE: Write pseudocode for a program that prints a calendar such as the following. Problem 15RE Problem 16RE: Write pseudocode for a program that reads a student record, consisting of the students first and... Problem 17RE: Write pseudocode for a program that reads a sequence of student records and prints the total score... Problem 18RE: Rewrite the following for loop into a while loop. int s = 0; for (int i = 1; i = 10; i++) { s = s +... Problem 19RE: Rewrite the following do loop into a while loop. int n = in.nextInt(); double x = 0; double s; do {... Problem 20RE: Provide trace tables of the following loops. a. int s = 1; int n = 1; while (s 10) { s = s + n; }... Problem 21RE: What do the following loops print? Work out the answer by tracing the code, not by using the... Problem 22RE: What do the following program segments print? Find the answers by tracing the code, not by using the... Problem 23RE Problem 24RE: Add a storyboard panel for the conversion program in Section 4.6 on page 164 that shows a scenario... Problem 25RE: In Section 4.6, we decided to show users a list of all valid units in the prompt. If the program... Problem 26RE: Change the storyboards in Section 4.6 to support a menu that asks users whether they want to convert... Problem 27RE: Draw a flowchart for a program that carries out unit conversions as described in Section 4.6. Problem 28RE: In Section 4.7.5, the code for finding the largest and smallest input initializes the largest and... Problem 29RE: What are nested loops? Give an example where a nested loop is typically used. Problem 30RE: The nested loops for (int 1 = 1; 1 = height; i++) { for (int j = 1; j = width; j++) {... Problem 31RE: Suppose you design an educational game to teach children how to read a clock. How do you generate... Problem 32RE: In a travel simulation, Harry will visit one of his friends that are located in three states. He has... Problem 1PE: Write programs with loops that compute a. The sum of all even numbers between 2 and 100 (inclusive).... Problem 2PE: Write programs that read a sequence of integer inputs and print a. The smallest and largest of the... Problem 3PE: Write programs that read a line of input as a string and print a. Only the uppercase letters in the... Problem 4PE: Complete the program in How To 4.1 on page 171. Your program should read twelve temperature values... Problem 5PE: Write a program that reads a set of floating-point values. Ask the user to enter the values, then... Problem 6PE: Translate the following pseudocode for finding the minimum value from a set of inputs into a Java... Problem 7PE: Translate the following pseudocode for randomly permuting the characters in a string into a Java... Problem 8PE: Write a program that reads a word and prints each character of the word on a separate line. For... Problem 9PE: Write a program that reads a word and prints the word in reverse. For example, if the user provides... Problem 10PE: Write a program that reads a word and prints the number of vowels in the word. For this exercise,... Problem 11PE: Write a program that reads a word and prints the number of syllables in the word. For this exercise,... Problem 12PE: Write a program that reads a word and prints all substrings, sorted by length. For example, if the... Problem 13PE: Write a program that reads a string and prints the most frequently occurring letter. If there are... Problem 15PE: Write a program that reads a sequence of words and then prints them in a box, with each word... Problem 16PE: Write a program that prints all powers of 2 from 20 up to 220 Problem 17PE: Write a program that reads a number and prints all of its binary digits: Print the remainder number... Problem 18PE Problem 19PE: Write a program that reads an integer and displays, using asterisks, a filled and hollow square,... Problem 20PE: Write a program that reads an integer and displays, using asterisks, a filled diamond of the given... Problem 25PE: Write a program to plot the following face. Problem 26PE: Write a graphical application that displays a checkerboard with 64 squares, alternating white and... Problem 1PP: Enhance Worked Example 4.1 to check that the credit card number is valid. A valid credit card number... Problem 2PP: Mean and standard deviation. Write a program that reads a set of floating-point data values. Choose... Problem 3PP: The Fibonacci numbers are defined by the sequence f1 = 1 f2 = 1 fn = fn1 + fn2 Reformulate that as... Problem 4PP: Factoring of integers. Write a program that asks the user for an integer and then prints out all its... Problem 5PP: Prime numbers. Write a program that prompts the user for an integer and then prints out all prime... Problem 8PP: The game of Nim. This is a well-known game with a number of variants. The following variant has an... Problem 9PP: The Drunkards Walk. A drunkard in a grid of streets randomly picks one of four directions and... Problem 10PP: The Monty Hall Paradox. Marilyn vos Savant described the following problem (loosely based on a game... Problem 11PP: A simple random generator is obtained by the formula rnew = (a rold + b)%m and then setting rnew to... Problem 12PP: The Buffon Needle Experiment. The following experiment was devised by Comte Georges-Louis Leclerc de... Problem 13PP: In the 17th century, the discipline of probability theory got its start when a gambler asked a... Problem 15PP: Write a program that reads an initial investment balance and an interest rate, then prints the... Problem 16PP: Currency conversion. Write a program that first asks the user to type todays price for one dollar in... Problem 17PP: Write a program that first asks the user to type in todays price of one dollar in Japanese yen, then... Problem 18PP: Your company has shares of stock it would like to sell when their value exceeds a certain target... Problem 19PP: Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4... Problem 20PP: You need to control the number of people who can be in an oyster bar at the same time. Groups of... Problem 21PP: Credit Card Number Check. The last digit of a credit card number is the check digit, which protects... Problem 22PP: In a predator-prey simulation, you compute the populations of predators and prey, using the... Problem 23PP: Projectile flight. Suppose a cannonball is propelled straight into the air with a starting velocity... Problem 25PP: Radioactive decay of radioactive materials can be modeled by the equation A = A0et(log 2/h), where A... Problem 26PP: The photo at left shows an electric device called a transformer. Transformers are often constructed... Problem 27PP: Write a graphical application that draws a spiral, such as the following: Problem 28PP Problem 29PP: Draw a picture of the four-leaved rose whose equation in polar coordinates is r = cos(2). Let go... format_list_bulleted