CS 55  Java Programming

Week 5

Agenda

Examples

BasicStatements.java - basic statements in Java
GradeCalculator.java  calculates a student's grade
Triples.java  Exercise 5.18 -- calculates Pythagorean Triples

References

Lecture Notes - Control Structures - based on Peter van der Linden's book Just Java

Lab05

  1. Exercise 5.6  Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user.
  2. Exercise 5.8  Factorials are used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced "n factorial") is equal to the product of the positive integers from 1 to n. Write an application that evaluates the factorials of the integers from 1 to 5. Display the results in tabular format in a JTextArea that is displayed on a message dialog (JOptionPane).
  3. Two extra credit points: Modify exercise 5.8 so that it prompts the user for an integer, n. It then evaluates and displays the factorials of the integers from 1 to n.
  4. Two extra credit points: Modify exercise 5.8 so that it also displays the largest value of n such that n! fits in a double without overflowing.
 < CS 55  > Home Email Last Modified September 28, 2004