Programs

| CS 100B Home |
| CUCS Stationery | Solutions | Iteration Examples | Additional Examples |

Many of the programs have been/will be distributed in Lecture and Sections. See also Handouts for further information.

CUCS Stationery

The following files are copied from the CUCS Stationery. No guarantee these work, since I pulled out of
CodeWarrior, but they seem to work OK with JDK:
TokenReader.java
Format.java
CUCSGraphicsApplication.java

Solutions
Look here for solutions to programming assignments.
Look here for solutions to prelims and sample prelims.

Iteration Programming Examples
 
Iteration
Examples
while
(a)
do-while
(b)
for
(c)
(1) repeat
1a
1b
1c
(2) sum
2a
2b
2c
(3) find/sort
3a
3b
3c

Additional Examples

Please note:

  • The following code leaves most documentation up to you.
  • You might find some discrepancies between the lecture and files here.
  • Use at your own risk. You really should carefully test and try similar examples.

  •  
    Date Description Program
    Sept Iteration See "Iteration
    Programming
    Examples"
    Sept Nested iteration nested_lhs.java
    10/5 Person class (basics of OOP) Example.java
    10/5 chap4 class (revised example from pg137-139) chap4.java
    10/7 Using Format.java from CUCS Stationery test_format.java
    10/7 Encapsulation Example Encaps.java
    10/11 Another Encapsulation example (courtesy of M. Singer) Encaps2.java
    10/12 Another nested loop (courtesy of D. Goldberg) ident.java
    10/12 Yet another nested loop (courtesy of R. Rohde)
    (see also nested_lhs.java)
    loops.pdf
    loops.ps
    10/13 Using final Final_test.java
    10/13 Static Variables Static_var.java
    10/13 Static Methods Static_meth.java
    10/17 How to return an interval from an interval method (I strongly suggest reviewing this example). returning_interval.java
    10/19 What kinds of variables can main access? local and static Static_meth2.java
    10/19 Method overloading
    (uses Encaps.java)
    overload.java
    10/21 Array 1: the basics array1.java
    10/21 Array 2: common errors array2.java
    10/25 Arrays of primitive types array_types.java
    10/25 Arrays of objects array_objects.java
    10/25 Passing arrays array_params.java
    10/27 Declaring arrays array_declare.java
    10/27 Returning arrays from a method array_return.java
    10/27 Array of arrays (have caution) array_of_arrays.java
    10/27 2D Array array_2d.java
    10/31 Array of objects with static fields array_static.java
    10/31 Prompting for input prompt_user.java
    10/31 Array lengths array_length.java
    10/31 More about array lengths array_length2.java
    10/31 Even more about array lengths array_length3.java
    10/31 Can you mix types in an array? array_mixedtypes.java
    10/31 How can you simulate a mixed type in an array? array_mixedtypes2.java
    11/1 Inheritance: basic example extend1.java
    11/1 Inheritance: bit more detailed extend2.java
    11/1 Inheritance: using protected to improve encapsulation protected1.java
    11/1 Inheritance: using super to inherit constructors super1.java
    11/1 Inheritance: difference between defined and inherited defined1.java
    11/3 Inheritance: does an object instantiated from a subclass access stored 
    information from an object instantiated from a superclass.
    extend3.java
    11/3 Inheritance: overriding a method override1.java
    11/3 Inheritance: overriding and using a method from a superclass override2.java
    11/3 Inheritance: class hierarchies hierarchy.java
    11/3 Inheritance: class hierarchies hierarchy2.java
    11/6 Chapter 14 (for section): exceptions except1.java
    11/6 Chapter 14 (for section): more exceptions except2.java
    11/6 Chapter 14 (for section): even more exceptions except3.java
    11/6 Chapter 14 (for section): threads thread1.java
    11/8 Chapter 14 (for section): checked exceptions (alternative HW1 solution, too) except4.java
    11/8 Chapter 8: polymorphism polym1.java
    11/8 Chapter 8: polymorphism polym2.java
    11/8 Chapter 9: abstract classes abstract1.java
    11/8 Chapter 9: interfaces interface1.java
    11/10 Chapter 13: storing arrays in a class (yet another array example!) array_store.java
    11/10 Chapter 13: select sort select_sort.java
    11/10 Chapter 13: combining all kinds of things: storing arrays, encapsulation, select sort, insert sort sorting.java
    11/10 Chapter 13: linear search (see also "Find/Sort" in Iteration Examples) linear.java
    11/10 Chapter 13: bisecting search (see also Homework 2 solutions) bisection.java
    11/11 Chapter 4: Samples:  do 4.19 and 4.20 from L&L -- solutions posted Sun or Mon portion4.pdf
    11/12 Chapter 8: Samples:  do 8.13, 8.14, 8.16 from L&L -- solutions posted Sun or Mon portion8.pdf
    11/29 MATLAB: Example script example.m
    12/8 Practice: aliases and methods (see pg 226) aliases_methods.java
    12/8 Practice: aliases and methods aliases_meothds2.java
    12/8 Practice: random arrays array_random.java
    12/8 Practice: boolean values boolean1.java
    12/8 Practice: encapsulation encaps1.java
    12/8 Practice: using super for constructor and method super2.java
    12/11 Question during review session: can super access a private method? super_private.java
    The Future More To Come Keep looking...


    Back to Top
    Back to CUCS Stationery  SolutionsIteration Examples Additional Examples
    Back to CS100B Home