What's New
- FinalReview.java: Review program from 12/12 class
- FinalReview2.java: Review program from 12/14 class
- Are you interested in working as a TA, grader, or tutor next semester? You could help out with a class, or work as a tutor in the ACRC - all those jobs are by instructor recommendation only. So if you're interested, send me an e-mail and I'll tell you more about it: cpersiko@ccsf.edu
- The final exam is on Tuesday, December 19 from 10:30-12:30 covering all of the topics from the semester.
- The last day to submit late homework is Wednesday, December 20. Grades will be available on Canvas on December 21 and 22.
Miscellaneous Information:
Assignments:
Class Notes:
Sample Programs:
Chapter 2: Java Fundamentals
- HelloWorld.java: Demonstrates simple console output
- Echo.java: Here is an example demonstrating the use of variables, and of the
Scanner class for console input.
- Names.java: Solution to In-class exercise: inputs and outputs names.
- CalcFormatDemo.java: Demonstrates calculations and
formatting with printf.
- GradeAverage.java: Solution to in-class exercise averaging grades
- Example finding the average word length in a document.
- StringDemo.java: Shows various ways to manipulate strings.
- Busses.java: Solution to in-class exercise with wedding guests on busses
Chapter 3: Decision Structures
- Interest.java calculates interest on an investment at one of 2 rates
- NamesAndAges.java: Solution to in-class exercise with simple if-statements
- MoreInterest.java A version of
the above program, with more if-statements, more interest rates.
- NamesAndAgesPart2.java: Solution to in-class exercise with
if-else if-else
- BooleanApp.java demonstrates Boolean values and
multi-way if-statements
- NamesAndAgesPart3.java: Solution to in-class exercise with
if-else if-else and logical and (&&)
- SwitchGrades.java demonstrates switch statements
- ZipCodes.java: Solution to in-class
exercise to determine city from ZIP code, using switch
Chapter 4: Loops
- Invest.java uses a loop to add up interest
on an investment over time
- InvestAgain.java: Variation of above Invest program that
allows user to repeat the calculation as many times as user wants.
- Hellos.java: Solution to in-class
exercise repeating "hello" on screen
- Retire.java calculates results of monthly
retirement savings, using printf for formatting output
- NestedControlStructure.java inputs and shows student
info with if-else-if inside loop
- NestedAlt.java: Alternate version of above using "break"
- AverageNumbers.java: Solution to in-class
exercise to average and count numbers input by user
- Here's a document summarizing and demonstrating best
practices in code formatting.
- InvestFor.java: Solution to in-class
exercise. Same as Invest.java, but using a for-loop instead of a while-loop.
- RandomExercise.java: Generates random numbers in a loop, stopping when 2 in a row match, outputs largest.
- AddMoney.java demonstrates switch statements, for
loops, and boolean varaibles
- NestedBrackets.java: Solution to in-class exercise with
nested loops, to output brackets.
Chapter 5: Methods
- FunInterest.java demonstrates the definition and
use of a method.
- Area.java Solution to in-class exercise using a method to calculate
area of a rectangle
- RandomExerciseMethod.java - a variation of the
In-class exercise solution to generate random numbers: uses a void method.
- NestedBracketsMethod.java: solution to in-class exercise to use a
method with Nested Bracket exercise from Chapter 4.
- InflationBetter.java - Uses several methods,
calculates inflation rate.
- Solution to Days Out Exercise: DaysOut.java
- Groups.java - demonstrates using shared static class variables and
output with nested loops.
- GroupsBetter.java - Variation of above program, without shared
static class variable for numGroups.
- AddMoneyFun.java uses 2 methods with
loops, switch statements, etc. (a variation of the AddMoney.java program above)
- Blackjack.java uses several static methods and
instance varaibles.
- DrawRectangle.java: solution to in-class exercise to output a
rectangle, using methods.
Chapter 6: Arrays
- BasicArray.java - Inputs and averages an array
of doubles.
- NameArray.java Solution to in-class exercise #1
- ArrayElementArguments.java - Demonstrates how to pass an
element of an array into a method.
- ArrayParam.java - Demonstrates how array
parameters work
- ReturnArray.java - shows how to create an
array in a function and return it
- MethodToInputArray.java Solution to in-class exercise
with a method to return an array of numbers
- SearchGroup.java - Sequential search example, searches an array of
student IDs to see if user-entered ID is in the array.
- ArrayExp.java - Inputs and sorts an array of
ints.
- SearchNameFixed.java Solution to in-class exercise 3, searching for a name out of a hard-coded list of names
- DeleteCommandLine.java Command-line arguments give the program a list of numbers, from which the user picks one to delete.
- SearchName.java Solution to first part of in-class
exercise 4, searching for a name out of a list specified on the command line
- DeleteName.java Solution to second part of in-class
exercise 4, to delete the name found
- DeleteAllNames.java Modified solution to in-class
exercise #4 to delete all instances of the name that is found
- FirstNumberDup.java Solution to in-class exercise 4.5 to tell the user if the first
element of an array is duplicated.
- QuarterlySales.java - a 2-Dimensional array example
- Pixels.java - Models screen pixels with a 2-D
array.
- JaggedArray.java - Shows how a 2-D array can be jagged:
have different numbers of columns for each row. Inputs test scores for courses - each course can have
a different number of tests.
- PixelDrawing.java: Solution to exercise #5. Demonstrates drawing with a 2-dimensional array of integers
- Solution to exercise #7: a program that inputs numbers on the command line
and then displays all of them except for the max
Last updated: 12/14/17 12:05pm