CSCI 1320 (Principles of Computer Science I):
Sample Programs
Disclaimer: Code linked from this page is intended as a
cleaned-up and commented version of examples from class.
Many programs could be further improved with
regard to functionality or design, but then they would
no longer be as close to what we did in class.
Programs
- "Hello, world" program (8/29)
hello.scala.
- Several versions of program to count out change (9/12)
change.scala,
change2.scala (incomplete),
change3.scala.
- Another version of program to count out change (9/17)
change4.scala.
- Prototype program to compute grade (9/17)
grades.scala.
- Prototype program to compute grade, slightly improved version
with function (9/19)
grades.scala.
- Preliminary/incomplete version of function to solve quadratic equation (9/19)
roots.scala.
- Factorial functions (10/01)
factorial.scala.
- Program to "count down" using recursion (10/01):
countdown.scala.
- Program to sum numbers using recursion (10/01):
sum.scala.
- Fibonacci function (10/03)
fibonacci.scala.
- Program to maintain running balance for checkbook (10/03)
checkbook.scala.
- Demo program for arrays (10/15, 10/17)
array-demo.scala.
- Demo program for lists (10/15, 10/17)
list-demo.scala.
- Function to check whether a string is a palindrome (10/22)
palindrome.scala.
- Function to compute variance of list (10/22)
variance.scala.
- Program to sum integers using loop (10/29)
sum-loop.scala.
- Demo programs for arrays, lists using loops (10/31)
array-demo-loop.scala,
list-demo-loop.scala.
- Program to maintain running balance and transaction history for
checkbook, preliminary version (10/31):
checkbook-transactions.scala.
- Program to sum integers read from file (11/05)
sum-from-file.scala.
- Program to echo command-line arguments (11/07)
echo-args.scala.
- Program to maintain running balance and transaction history for
checkbook, version using file (11/07):
checkbook-transactions-file.scala.
- Program to maintain running balance and transaction history for
checkbook, version using case classes (11/14):
checkbook-transactions-case-class.scala.
- Program to sum integers read from file,
version that catches common errors (11/14):
sum-from-file-catch-errors.scala.
- Function to sort array of numbers using bubble sort (11/26):
bubble-sort.scala.
- Example GUI programs (11/28):
"Hello world"
gui-hello.scala.
Simple editor
simple-editor.scala.
Calculator prototype
calculator-prototype.scala.
Drawing-program prototype
drawing-prototype.scala.
Simple animation example
simple-animation.scala.
Other files