Demonstration Programs
Input and output
- SimpleIO.java: simple input/output
- SimpleIO2.java: simple input/output
Simple arithmetic
- SimpleMath.java: simple calculation
- SimpleMath2.java: simple calculation
- IntCalc.java: 9/7/2007 in-class demonstration
Modules/methods/functions/subroutines part I
- IntCalc2.java: IntCalc redone with methods (modules)
- ModTest1.java: Area and perimeter problem done with modules
- ModTest2.java: Reorganized ModTest1.java demonstrating more standard Java coding
Selection
- SingleBranch.java: use of "if" statement for branching
- TwoBranch.java: use of "if-else" statement for 2-way branching
- MultiwayBranch1.java: "switch" statement for figuring out month name
- MultiwayBranch2.java: nested "if-else" version of MultiwayBranch1.java
- MultiwayBranch3.java: shortened version of MultiwayBranch3.java
- MultiwayBranch4.java: "switch" statement used to calculate days in a month
- MultiwayBranch5.java: year-aware version of MultiwayBranch4.java
- MultiwayBranch6.java: MultiwayBranch5.java with input validation
Formatted output
- TestPrintf.java: demonstration of printf() method
Repetition
- Loops1.java: basic loop demonstration
- Loops2.java: what happens when start value doesn't meet loop test
- Loops3.java: accumulating values in a loop
- Loops4.java: using a loop counter modification other than +1
- Loops5.java: a loop controlled by a sentinel value
- AverageAge.java: loop with priming read
- CalculateGPA.java: loop that calulates GPAs
- CheckForPrime.java: loop to check for prime number
- CheckForPrime2.java: nested loop to check for prime numbers
- SlowCounter.java: simple counting loop and delay
- RollDice.java: simple loop and random number generation
File processing
- TestFile1.java: simple sequential input and output
- MakeInv1.java: creates data file for in-class demonstration
- invdata.txt: the data file created by the previous program
- InvRpt1.java: creates inventory report file from inventory data file
- InvReport.txt: inventory report created by previous program
- InvRpt2.java: displays inventory report file on screen
- TestFile1R.java: simple random access input and output
- MakeInv1R.java: creates data file for in-class random access demonstration
- InvRpt1R.java: creates inventory report file from RA inventory data file
- InvReportR.txt: inventory report created by previous program
- InvRpt2R.java: displays inventory report file on screen
Modules/methods/functions/subroutines part II
- Method1.java: basic user-defined methods
- Method2.java: methods returning void
- Method3.java: methods returning values
- Method4.java: passing by value
- Method5.java: passing reference variables
- Method6.java: passing Strings
- Method7.java: overloading methods
- Method8.java: payroll calculation using multiple methods
- AreaCalculator.java: simple method demonstration
- Factorial.java: recursive method demonstration
- DisplayTruthTable.java: displays a truth table
Control breaks/level breaks
- Create1.java: creates sequential file for control break report
- Check1.java: displays info about file created by Create1.java
- Display1.java: displays file created by Create1.java
- Display2.java: a control break report program which handles the
data created by Create1.java
- Complete cycle of writing file, reading file, sorting data, and creating report (sequential text files)
- AddToEmployeeFile.java: sequential access file output
- DisplayEmployeeFile.java: sequential file input
- SortEmployeeFile.java: reads file records into parallel arrays and sorts
- SortEmployeeFile2.java: create object to hold data, read records into ArrayList, use Collections sort
- EmployeeControlBreakReport.java: creates control break report
- Complete cycle of writing file, reading file, sorting data, and creating report (random access files)
- AddToEmployeeFileR.java: random access file output
- DisplayEmployeeFileR.java: random access file input
- SortEmployeeFileR.java: reads file records into an array and sorts them
- SortEmployeeFileR2.java: create object to hold data, read records into ArrayList, use Collections sort
- EmployeeControlBreakReportR.java: creates control break report
Arrays
- Array1.java: using arrays, passing arrays to subs/functions
- Array2.java: reading array elements from a file; dealing with partially filled arrays
(peoplej.txt data file)
- Array0.java: using "String[] args" to get command line arguments
- Array1.java: basic array usage; passing arrays to methods
- Array2.java: reading array data from a file; dealing with partially filled arrays
- Array3.java: processing file data before saving it in an array;
using methods to process data
- Array4.java: reading parallel arrays from file
- Array5.java: linear searching of arrays; using parallel arrays
- Array6.java: sorting parallel arrays
- Array7.java: using arrays of objects
- 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)
- Array9.java: reading an indeterminate number of items into an array with error checking
Searching and sorting
- Search.java: linear and binary searching
- Sort.java: various sorting algorithms
Return Links
Mr. Klick's Home Page