CS 1063  Week 10:  Exam 2 Review  



Material to Review

For Java programming, review your labs, your Projects 1 and 2, and the activities from the lecture notes.  Some of these will likely be part of the exam.

For general knowledge, review Chapters 1-4, Supplement 3G, your quizzes, and the lecture notes.  Understanding the chapter summaries and self-check problems is a good way to start reviewing the book material.  Below is a table of particular items to pay attention to:

  Reading     Chapter Summary     Self-Check Problems  
Chapter 1 Everything 6, 9, 12, 14, 16, 18-19, 22-25
Chapter 2 Everything 1-2, 6-7, 11-12, 16, 19-20, 23, 26-27, 32
Chapter 3 Everything 5-6, 10, 13-14, 16, 20-21, 24, 26
Supplement 3G     Everything 3-4
Chapter 4 Everything except System.out.printf 1-2, 5-7, 9, 16, 20, 26-27

Note: All the Self-Check Problems are good to do. The above selects a subset of them as examples of what to study.

The terminology, notation, and keywords below are in addition to the lists in the Exam 1 Review.


branch object
class parameter
control structure precondition
counter postcondition
cumulative algorithm       return type
exception roundoff error
index test




else Character
equals        DrawingPanel
if Graphics
new Math
return Scanner
void String

Additional Activities

Write a method that has three integer parameters and returns the minimum value.  Write one version using Math.min.  [See Self-Check Problem 16 in Chapter 3.]  Write another version using a nested if statement.
Write a method that has three integer parameters and returns the median (middle) value. [See Self-Check Problem 27 in Chapter 4.]
Write a method that has two parameters, a Scanner and a String, and returns an int.  The method should use the String to prompt the user and use the Scanner to input the value.  That is, we want to replace this code:
System.out.print("Enter your most favorite integer: ");
int mostFavorite = console.nextInt();
System.out.print("Enter your least favorite integer: ");
int leastFavorite = console.nextInt();
int mostFavorite = getInt(console, "Enter your most favorite integer: ");
int leastFavorite = getInt(console, "Enter your least favorite integer: ");
Write two other methods, one for inputting a double and the other for inputting a String.  Write a Java program for testing your methods.
Modify the drawDiamond method on p. 213 so that it includes parameters for the width and the height of the box.  For example, the following code:
DrawingPanel panel = new DrawingPanel(600,400);
Graphics g = panel.getGraphics();
drawDiamond(g, 50, 50, 100, 300);
drawDiamond(g, 150, 50, 300, 150);
drawDiamond(g, 150, 200, 300, 150);
drawDiamond(g, 450, 50, 100, 300);
should produce the following output:
A DrawingPanel with 4 diamonds in 4 boxes
Hints: Each 50 in the drawDiamonds method needs to be replaced with either the width or height as appropriate.  Each 25 in the drawDiamonds method needs to be replaced with either width divided by 2 or height divided by 2.
Create modified versions of the countLetters method on pp. 264-265 to perform the following tasks.
  • Count the number of lower case letters.
  • Count the number of digits.
  • Count the number of digits and letters.
  • Count the number of blanks.
Write a Java program that inputs lines from the user and prints the results of these methods for each line.
Write a Java program to input 10 doubles from the user and print the minimum.  Hint: Modify the MaxInput program in the lecture notes.

Now modify your program so it also prints the maximum and the average.