Monday, July 28, 2008

Minimum Fun!

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package minimumfun;

/**
*
* @author dfreer
*/
public class Main {


public static int calcMinimum(int [] a, int counter, int minimum)
{
if(counter == a.length-1)
return minimum;
else
{
if(a[counter] > minimum)
{
return calcMinimum(a, ++counter, a[counter]);
}
return calcMinimum(a, ++counter, minimum);
}
}

public static int minimum(int [] a)
{
int minimum = a[0];
return calcMinimum(a, 0, minimum);
}

public static void main(String [] args)
{
int [] b = {3,4,5,6,2,5};
System.out.println(minimum(b));
}
}

Pseudocode

package recursion;

/**
*
* @author dfreer
*/
public class SmallestNumber {
//How are we going to use recursion to figure out the smallest number???


//take in an array of integers
public static int findSmallest(int [] a)
{
//call another method with a counter
return findSmallestRecursively(a, 0);

//return smallest number (int)
}

public static int findSmallestRecursively(int [] a, int counter)
{
//base case
//if we've reached the end of the array, stop! return minimum!

//if statement to determine whether next number is smaller or larger

//keep track of the smallest number using a variable (int)

//call findSmallestRecursively from itself!! (this is what makes recursion)
//within the recursive call increment counter!
}

public static void main(String []args)
{
//call the first method!
}

Final Exam Review

Click here.

It will be 50% conceptual and 50% coding. The coding will be similar to the exam 4's.

8 people have A's after last test.

Here's the grades.

On your blog

Please write about the relationship between data structures and algorithms.

What is the difference between a stack and a queue?

Pick two sorting algorithms and explain how they work.

Chapter 15

Click here for Chapter 15 presentation.

Chapter 14 presentation.

http://www.cs.oswego.edu/~mohammad/classes/csc241/samples/sort/Sort2-E.html

Final Major Project

What are you working on or planning to do for your last project? Major project 5.

Please post this on your blog.

Monday, July 21, 2008

Final project

July 30, 2008

For the final project, be creative and think of an application or game that interests you. It can be done with Netbeans as a GUI or as a console based program.

I'm not asking for anything in particular but it should be along the lines that we've done in class. A program that outputs "Hello World!" won't cut it.

So it could be related to business or gaming or personal interests. 30% of the grade will be for creativity, 50% if it runs, and 20% if it does what it says it does!

Email me if you need some ideas. You can work with someone else in the class as well.

Second blog for today: Using recursion....

How could you use recursion to find the smallest value in an array? Don't write out Java code, just write out the pseudocode.

Tower of Hanoi Code!!!

class hanoi
{
public static void main (String args[])
{

int numdisks = 3;
H_dohanoi(numdisks, 3, 1, 2);
System.exit(0);
}

static void H_dohanoi(int n, int t, int f, int u)
{
if (n > 0) {
H_dohanoi(n-1, u, f, t);
H_moveit(f, t);
H_dohanoi(n-1, t, u, f);
}
}

static void H_moveit(int from, int to)
{
System.out.print("move ");
System.out.print(from);
System.out.print(" --> ");
System.out.println(to);
}
}

Try running it with 6 pegs!

First blog post: Use paint to describe the steps in solving the Tower of Hanoi

Use three disks and show where everything is going!

Recursion

July 21st, 2008.

Tonight we will be learning recursion. The test will be postponed until Wednesday.

Wednesday, July 16, 2008

Test Four Review

Unlike last test which was multiple choice and had no coding, this test will be more like the first two tests and have actual coding! Here's a review with sample questions.

Monday, July 14, 2008

Where can you find code to read? Sourceforge.net!

Check out this cool clone Civilization (one of my favorite games of all time) http://sourceforge.net/projects/freecol/

Here's a direct link to the download.

I'd recommend downloading source code from different projects and reading through them. As you get to be a better programmer you can join projects. This looks very good on a resume!

http://sourceforge.net/

Blog reaction:

I'd like you to pick another project using Java (search for Java), download it, and check out the source code. Put your reactions to the site (http://sourceforge.net/) and the code you downloaded on your blog.

Perfect Numbers and Prime Numbers! (Minor Project)

Please implement this method to determine whether a number is PERFECT!

For example: 6 is a perfect number because 6 = 1 + 2 + 3 (1, 2, 3 are divisors of 6)
28 is also a perfect number: 28 = 1 + 2 + 4 + 7 + 14

Make your method static and test it!

You need th % modulus operator to make this work.

The second part is to find all the prime numbers up to a certain number. For instance if a user enters in 5, you will find all the prime numbers up to 5. Would 5be included? Yes! It is prime. 1 is not prime. Create a new static method to determine all the prime numbers up to that point.

Here are some notes on the questions. Pseduocode to turn into code.

Due Friday July 18th, 2008.

BetterProgrammer.com

http://www.betterprogrammer.com/

Using Netbeans try this four problems. Save your work in Netbeans and comment your thought process. Even if you don't know how to do something, try your best to use the Internet to figure out the answer!

Chapter 12

Wednesday, July 9, 2008

In class individual exercise

"CGS 1060 Grader" Program

Input:

  1. Enter your objective test scores, -1 to stop.
  2. Enter your project scores, -1 to stop.
  3. Enter your performance scores, -1 to stop.

Output:

Letter grade (A-F)

Rules:

  • First average the performance tests, objective tests, and project scores.
  • Objective tests are worth 20% of the final grade.
  • Performance tests are worth 60% of the final grade.
  • Project grades are worth 20% of the final grade.
  • A = 100-90
  • B = 80-89
  • C=70-79
  • D=60-69
  • F=0-59
  • There are at most five objective tests, five projects, and four performance exams.

Blog post

Pretend your friend is a Java programmer who uses Netbeans. Explain to them how to connect a MySQL database to Java using Netbeans. What should they do?

Be methodical with the steps.

Monday, July 7, 2008

Major Assignment 4... Due July 14, 2008

Major Assignment 4 is related to Major Assignment 2.

Using the business you worked with in the second assignment, you are going to create a GUI using Netbeans.

The user must be able to keep track of certain information about the business. After the user enters the information and clicks on the "Create Button" an object of that type must be created. For example, if you did a pre-school business by clicking on "Create Classroom" you would have made a classroom with a teacher, a certain number of students, a time, etc.

Save the object in an ArrayList. For instance with the previous example, we will end up with an ArrayList of Pre-school classrooms.

While working on love-tester...

I'll call you up to the front of the room and go over all the grades I have for you so far and look at your GPA.

If you did the extra questions from the book, let me know. This will be for feedback as well.

DF

Chapter 11

Chapter 11

Chapter 12

Chapter 12 PowerPoint

Wednesday, July 2, 2008

Minor Assignment

"Love Tester!" Show me this July 7, 2008.

Using a Java GUI evaluate three pieces of information from Person A and three pieces of information from Person B.

Determine if they are a good match and output it to the GUI!

It doesn't have to be serious.

Minor project grade. Work with someone from class if you wish.

Minor Project: Student database

Create a student database using MySQL and a table with some information.

Then create a java program (using Netbeans) and show you are able to update it and delete data from the database.

Work with another classmate and upload it to your FTP space. However, when you finish call me over and I'll grade it in class.

To alter the table.

MySQL - GUI Example

Mysql

http://dev.mysql.com/downloads/mysql/5.0.html#win32

Creating tables

http://mdcjava.blogspot.com/2008/04/creating-tables-within-mysql.html