Demonstration Programs

Input and output

  1. SimpleIO.java: simple input/output
  2. SimpleIO2.java: simple input/output

Simple arithmetic

  1. SimpleMath.java: simple calculation
  2. SimpleMath2.java: simple calculation
  3. IntCalc.java: 9/7/2007 in-class demonstration

Modules/methods/functions/subroutines part I

  1. IntCalc2.java: IntCalc redone with methods (modules)
  2. ModTest1.java: Area and perimeter problem done with modules
  3. ModTest2.java: Reorganized ModTest1.java demonstrating more standard Java coding

Selection

  1. SingleBranch.java: use of "if" statement for branching
  2. TwoBranch.java: use of "if-else" statement for 2-way branching
  3. MultiwayBranch1.java: "switch" statement for figuring out month name
  4. MultiwayBranch2.java: nested "if-else" version of MultiwayBranch1.java
  5. MultiwayBranch3.java: shortened version of MultiwayBranch3.java
  6. MultiwayBranch4.java: "switch" statement used to calculate days in a month
  7. MultiwayBranch5.java: year-aware version of MultiwayBranch4.java
  8. MultiwayBranch6.java: MultiwayBranch5.java with input validation

Formatted output

  1. TestPrintf.java: demonstration of printf() method

Repetition

  1. Loops1.java: basic loop demonstration
  2. Loops2.java: what happens when start value doesn't meet loop test
  3. Loops3.java: accumulating values in a loop
  4. Loops4.java: using a loop counter modification other than +1
  5. Loops5.java: a loop controlled by a sentinel value
  6. AverageAge.java: loop with priming read
  7. CalculateGPA.java: loop that calulates GPAs
  8. CheckForPrime.java: loop to check for prime number
  9. CheckForPrime2.java: nested loop to check for prime numbers
  10. SlowCounter.java: simple counting loop and delay
  11. RollDice.java: simple loop and random number generation

File processing

  1. TestFile1.java: simple sequential input and output
  2. MakeInv1.java: creates data file for in-class demonstration
  3. invdata.txt: the data file created by the previous program
  4. InvRpt1.java: creates inventory report file from inventory data file
  5. InvReport.txt: inventory report created by previous program
  6. InvRpt2.java: displays inventory report file on screen
  7. TestFile1R.java: simple random access input and output
  8. MakeInv1R.java: creates data file for in-class random access demonstration
  9. InvRpt1R.java: creates inventory report file from RA inventory data file
  10. InvReportR.txt: inventory report created by previous program
  11. InvRpt2R.java: displays inventory report file on screen

Modules/methods/functions/subroutines part II

  1. Method1.java: basic user-defined methods
  2. Method2.java: methods returning void
  3. Method3.java: methods returning values
  4. Method4.java: passing by value
  5. Method5.java: passing reference variables
  6. Method6.java: passing Strings
  7. Method7.java: overloading methods
  8. Method8.java: payroll calculation using multiple methods
  9. AreaCalculator.java: simple method demonstration
  10. Factorial.java: recursive method demonstration
  11. DisplayTruthTable.java: displays a truth table

Control breaks/level breaks

  1. Create1.java: creates sequential file for control break report
  2. Check1.java: displays info about file created by Create1.java
  3. Display1.java: displays file created by Create1.java
  4. Display2.java: a control break report program which handles the data created by Create1.java
  5. Complete cycle of writing file, reading file, sorting data, and creating report (sequential text files)
    1. AddToEmployeeFile.java: sequential access file output
    2. DisplayEmployeeFile.java: sequential file input
    3. SortEmployeeFile.java: reads file records into parallel arrays and sorts
    4. SortEmployeeFile2.java: create object to hold data, read records into ArrayList, use Collections sort
    5. EmployeeControlBreakReport.java: creates control break report
  6. Complete cycle of writing file, reading file, sorting data, and creating report (random access files)
    1. AddToEmployeeFileR.java: random access file output
    2. DisplayEmployeeFileR.java: random access file input
    3. SortEmployeeFileR.java: reads file records into an array and sorts them
    4. SortEmployeeFile2R.java: create object to hold data, read records into ArrayList, use Collections sort
    5. EmployeeControlBreakReportR.java: creates control break report

Arrays

  1. Array1.java: using arrays, passing arrays to subs/functions
  2. Array2.java: reading array elements from a file; dealing with partially filled arrays (peoplej.txt data file)
  3. Array0.java: using "String[] args" to get command line arguments
  4. Array1.java: basic array usage; passing arrays to methods
  5. Array2.java: reading array data from a file; dealing with partially filled arrays
  6. Array3.java: processing file data before saving it in an array; using methods to process data
  7. Array4.java: reading parallel arrays from file
  8. Array5.java: linear searching of arrays; using parallel arrays
  9. Array6.java: sorting parallel arrays
  10. Array7.java: using arrays of objects
  11. Array8.java: using the Arrays class to sort an array of objects
    array8data.txt: data file for Array8.java (make sure after transferring data file that there is no blank line after last record and theat each record is on its own line)
  12. Array9.java: reading an indeterminate number of items into an array with error checking

Searching and sorting

  1. Search.java: linear and binary searching
  2. Sort.java: various sorting algorithms

Return Links

Mr. Klick's Home Page