2013

Mr Mulkey's IB Computer Science Blog
 * media type="custom" key="10402724" IB Comp Sci 2013 **

**Other IB Web-sites** : **SL Overview R Jones' Site Old Mulkey IBcomp site** **Reading : [|Eck's Java Notes]** Schmidt's Java Programming Course J[|ava Video Lessons] **Other Links: [|IBIO Functions]** IB Syllabus+Vocabulary [|School Calendar]


 * IA Dossier Project - 18 **** Jun 2012 **


 * Project -** Please have a look at these deadlines and add them to your personal calendar.



Here are some possibilities: [] http://chortle.ccsu.edu/CS151/cs151java.html http://www.java-made-easy.com/java-for-beginners.html http://funprogramming.org (need to use Processing from http://processing.org) [|Getting Started with Processing] (2nd half of book is good)
 * Practice Programming** - You should practice programming over the summer.


 * Extended Essays** - Plan on **READING, READING, READING** over the summer.


 * Multi-tasking in Java - 15 **** Jun 2012 **

BOINC won't work on our student PCs, due to account restrictions. If you want to try it yourself, you'll need to do it at home or with a MacBook at school.

Below is a program that adds up numbers, like 1+2+...+1000000. Using NetBeans, make a program that creates 5 identical windows, but with different numbers be added in each, for example:

1+2+...200000, 200001+200002+...400000, 400001+...600000....

Then figure out a way to add up the 5 results. Does this run faster, slower, or the same speed as using a single object to do all the adding from 1 to 1 million?

You probably need to use bigger numbers so that it takes around a minute, so it's possible to measure the differences in time.


 * BOINC - 14 Jun 2012 **

media type="custom" key="29489577"
 * BOINC ?**


 * [HL+SL] Performance in Java - 12 Jun 2012 **

We can write programs to test the computer's performance. Our program needs to run lots of other programs, OR it needs to do a task that requires lots of resources.

We will be discussing **algorithm efficiency.** We will start with this algorithm.

code format="javascript" public void Counting {     double sum = 0; double limit = Double.parseDouble(jTextField1.getText);

for(int x=0; x < limit; x=x+1) {        sum = sum + x;      }

jTextField2.setText("Sum = " + sum); }

code Make a Java program that contains this algorithm. It needs 2 text fields and a Button.

Try running many copies of the program simultaneously. Use the Task Manager to check the performance of the computer.

http://en.wikipedia.org/wiki/Computer_multitasking#Cooperative_multitasking.2Ftime-sharing
 * Homework - Read about Multitasking**


 * [HL] Performance - 12 Jun 2012 **

How do you notice that a computer is performing poorly?

- Find a program that requires a lot of RAM when loaded (over 100 MB) - Find a program that requires a lot of CPU cycles when loaded (over 30% of the CPU) - Find out how much RAM your home printer contains.
 * Homework**


 * Look Forward to IA Dossier Project - 11 Jun 2012 **

IA Dossier Project Notes : http://ibcomp.wikispaces.com/IAdossierNotes

Discuss final exam


 * Finished Homework Database - 1 Jun 2012 **


 * Study the Homework Database to prepare for the Final Exam.**

Here are notes with answers for all 15 questions.

Here is the [|finished Homework Database Program].

Here is the original reading and questions about the Homework Database: []

The final exam will include several programming questions about the Homework Database. During the exam, you will receive a [|copy of these notes]. Still, you should study this and make sure you understand the concepts. You will be expected to write answers to questions that are similar to #1-15 from the notes.

The exam will also contain other questions covering everything studied this year, with more emphasis on the second semester. Use this blog to review past topis.


 * Adding Grades to the HW DB - 30 May 2012 **


 * We will add GRADES to the Homework DataBase.**


 * [HL] Sorting Due Dates - 30 May 2012 **

[HL] Turn in your Tic-Tac-Toe game.

[HL] We will discuss how to SORT the Due Dates in the Homework Database.

code format="javascript" public void sortDueDates {       for(int x=0; x<countData-1; x++) {          int smallRow = findSmallest(x); swapRows(x,smallRow); }       showAllData; }

public int findSmallest(int start) {       int row = start; long smallest = dueDates[start]; for(int c=start; c < countData; c=c+1) {          long d = dueDates[c]; if(d<smallest) {              smallest = d;               row = c;           } }       return row; }

public void swapRows(int a, int b)   { String[] oneRow = allData[a]; String[] otherRow = allData[b]; allData[a] = otherRow; allData[b] = oneRow;

long ta = dueDates[a]; long tb = dueDates[b]; dueDates[a] = tb; dueDates[b] = ta;

}

String[][] allData = new String[100][5]; long[] dueDates = new long[100]; int countData = 0;

code


 * Load/Edit/Store/Next - 29 May 2012 **

Continue with the exam Case Study about the Homework Database: []

We will write code that loads a record, allows the user to edit that record, saves the result and then moves on to the next record.

code format="javascript" private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { // Get the record number out of the box // add 1 // put it back in the box // loadRecord long rec = Long.parseLong(recordNum.getText); rec = rec+1; recordNum.setText(rec+""); loadRecord; }

public void saveRecord {         try{ RandomAccessFile info = new RandomAccessFile("hw.dat","rw");

long rec = Long.parseLong(recordNum.getText);

long dateGiven = Date.parse(dateGivenBox.getText); long dateDue = Date.parse(dateDueBox.getText); String title = titleBox.getText; String subject = subjectBox.getText; String details = detailsArea.getText;

info.seek(rec * 1060); info.writeLong(dateGiven); info.seek(rec * 1060 + 8); info.writeLong(dateDue); info.seek(rec * 1060 + 16); info.writeUTF(subject); info.seek(rec * 1060 + 36); info.writeUTF(title); info.seek(rec * 1060 + 100); info.writeUTF(details);

info.close; }       catch(IOException ex) { System.out.println(ex.toString); } }

public void loadRecord {   try {       RandomAccessFile info = new RandomAccessFile("hw.dat","rw");

long rec = Long.parseLong(recordNum.getText);

info.seek(rec*1060 + 0); long dateGiven = info.readLong; String given = new Date(dateGiven).toLocaleString; int comma = given.indexOf(",")+6; given = given.substring(0,comma); dateGivenBox.setText(given);

info.seek(rec*1060 + 8); long dateDue = info.readLong; String due = new Date(dateDue).toLocaleString; comma = due.indexOf(",")+6; due = due.substring(0,comma); dateDueBox.setText(due);     //REFACTOR

info.seek(rec*1060 + 16); String subject = info.readUTF; subjectBox.setText(subject);

info.seek(rec*1060 + 36); String title = info.readUTF; titleBox.setText(title);

info.seek(rec*1060+100); String details = info.readUTF; detailsArea.setText(details);

info.close; }   catch(IOException ex) {       System.out.println(ex.toString); } } code

code format="javascript" private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { sortSubjects; }
 * Sorting Subjects - 23 May 2012 **

public void sortSubjects {       for(int pos=0; pos < countData; pos = pos+1) {          int best = findFirst(pos);

allData[99] = allData[pos]; allData[pos] = allData[best]; allData[best] = allData[99]; }       showAllData; }

public int findFirst(int pos) {       int bestRow = pos; String subject = allData[pos][2];

for(int r=pos+1; r < countData; r=r+1) {           String check = allData[r][2]; if(check.compareTo(subject) < 0) {               bestRow = r;                subject = check; }       }        return bestRow; } code


 * Changing Data - 23 May 2012 **

The following code lets the user click on the list of homework assignments, and then concatenates xxx to the beginning of the title and updates the Array, updates the Disk file, and updates the GUI screen. That is the solution to feature #12 in the Homework DB notes. code format="javascript" private void dataListMouseClicked(java.awt.event.MouseEvent evt) { // We are going to allow the user to  //  CLICK on an assignment to choose it

int num = dataList.getSelectedIndex;

// Now we have the record number. // We can go straight into the data file, // SEEK to the correct position, // READ the original title // ADD xxx at the beginning // then WRITE the new title back where we found it

allData[num][3] = "xxx" + allData[num][3];     // concatenate showAllData;

try {     RandomAccessFile info = new RandomAccessFile("hw.dat","rw");

info.seek(num*1060 + 36);                  // 36 = OFFSET info.writeUTF( allData[num][3]);

info.close; }  catch(IOException ex) { System.out.println(ex.toString); }

}

code


 * Homework-Database Prototype - 22-31 May 2012 **

The Final Exam is scheduled for June 8. The exam will cover everything done in the course this year, but concentrating on semester 2, so a good way to prepare is by using this web-page, as well as reading your notebook.
 * Final Exam Preparation**

The exam will contain several questions about the Homework Database problem. You should read the following and practice programming the features on page 3: []

We still have a few days of class and will do some of these programs in lectures.

Here is a solution for #6 = Show Tomorrow's Assignments code format="javascript" // get tomorrow by new Date + 1 day worth of milliseconds // Read through all data in array // Select the ones with DueDate = tomorrow

loadAllData; Date d = new Date; d.setHours(0); d.setMinutes(0); d.setSeconds(0); d.setDate(d.getDate+1); String tomorrow = d.toLocaleString; dataList.removeAll; for(int c=0; c < countData; c = c+1) {       if(allData[c][1].equals(tomorrow)) {           String all = allData[c][0]+ " ::: " + allData[c][1]+ " ::: "+allData[c][2] + " ::: "+allData[c][3]+ " ::: "+allData[c][4]; dataList.add(all); }   } code


 * Homework-Database Prototype - 21 May 2012 **

We will collect the homework.

Today we will see how to[| read and display an entire list of homework assignments.]


 * Today's Lecture Notes :** []

- Change it so that the big display list only shows the dates, not the times.
 * Today's Homework:**
 * - Download the [|newest HomeworkDB program].**

//... the extended Haiku test is over - we will go back to using WikiSpaces ...//
 * More Homework-Database Stuff - 15 May 2012 **

Start with the original HomeworkDB ([|link below]). Make sure it runs and will save a HW assignment into a file. Add a [LOAD] button. At first, this should READ the first record from info.seek(0) and put the data back onto the screen. You will need to add a TextField where the subject can be displayed. Then improve it so that it does a search, for example searching for a Math Homework assignment and displaying that. Finish this before Monday 21 May, or at least try to finish it - you needn't spend more than an hour on it. But that must be enough time to get the First record displayed.
 * Homework:**


 * [HL] Make Tic-Tac-Toe - 15 May 2012 **

Your HL assignment is to convert the Kings game into a Tic-Tac-Toe game. You don't need to change the interface, even though it is unattractive and badly aligned. We are concerned with the RULES FOR WINNING in Tic-Tac-Toe. In this version, the board will have 5 rows and 5 columns. You win by getting 4-in-a-row.

After each move, the program needs to check whether there is a winner. In each row there are 2 ways to win (0-1-2-3 or 1-2-3-4). In each column there are 2 ways to win. That makes 20 things to check. There are also diagonals, and not only the ones in the middle. Try to simplify the coding by using loops and methods so that you aren't just copying and pasting. Bring the finished program to class in the next HL meeting - that will be on Wed May 30.


 * Data-Structures for Databases - 14 May 2012 **

- - - - - - -
We will look at this sample program for a Homework Database:
 * @http://dl.dropbox.com/u/239179/ibcomp/2darrays/HomeworkDB.zip

- - - - - - - - -

Here is the solution for the Kings move rules from last Wednesday: code format="javascript" public void move {         int row = inputInt("row"); int col = inputInt("column"); if(board[row][col]=='K') {             output("Occupied"); return; }         if(row>0 && board[row-1][col]=='K') {             output("There is a King above"); return; }         if(row<4 && board[row+1][col]=='K') {             output("There is a King below"); return; }         if(col>0 && board[row][col-1]=='K') {             output("There is a King to the left"); return; }         if(col<4 && board[row][col+1]=='K') {             output("There is a King to the right"); return; }         board[row][col] = 'K'; showBoard; }

code


 * Software Engineering - 11 May 2012 **

Homework - User Stories
Remember that you must bring **User-Stories** to class on Monday 14 May. That means: - you must already have a topic for you Internal Assessment Dossier (project) - you must already have chosen an **intended user** for your project - before Monday, you must have spent at least a half hour talking to your intended user about their problems and wishes - during your interview with the intended user, you must take NOTES about their comments - on Monday 14 May, you must **turn in** a written summary of the **User Stories** that came out of your interview with the intended user. These can be hand-written or typed, but they must be clear and legible Make your user stories similar to those shown in this Sample Dossier (p. 4): http://ibcomp.fis.edu/projects/quizTacToe/quizTacToeDocs.pdf You should have at least 3 or 4 stories on Monday, written or typed clearly, that you can turn in (on paper).

Acceptance Testing for StudyWiz Replacement - 11 May 2012
FIS wants to replace StudyWiz. We are looking for a different product, but with similar functionality. The new system should be easier to use and less confusing. We have identified 4 possible replacements. When choosing a replacement, it isn't enough to just look at the price and the specifications. We need to test each system to see how well it meets our needs. This is similar to an IB Dossier analysis. Actually, this task is at the END of the **Software Development Cycle,** which goes like this: **Problem (start here)** **==> Analysis (investigate problem, collect data, produce goals)** **==> Design (propose a solution, design modules and algorithms and data-structures)** **==> Implementation (build a solution, write a program)** **==> Installation (install the system, final (beta) testing, accept the system)** **==> Review (review the functioning solution, find problems or deficiency, prepare for a new analysis)** After this, the whole process starts over again and repeats. We will use the StudyWiz problem as a basis for discussing software development. - - - - - - - - - - -
 * HAIKU Extended Acceptance Test - 9 May 2012 **

https://fis.haikulearning.com/dave_mulkey/ibcomputerscience/prva/cms_page/view/1918661
You will need to log-in with your normal FIS log-in.


 * Kings - a 2D Array Game - 9 May 2012 **

- there is already a King - there is a King in a neighboring square You don't need to worry about diagonals - just above, below, left and right Notice that you will get Run-Time Errors at the edges of the board, if your program attempts to check locations that are not part of the board. You need to fix this. There are a couple hints in these notes in question (4): http://dl.dropbox.com/u/239179/ibcomp/2darrays/Kings.html
 * Homework** - improve the MOVE method by adding proper RULES, preventing the user from picking a square where:

You will have a QUIZ on Friday 11 May about this task.


 * Kings - a 2D Array Game - 7 May 2012 **

[|Kings - a 2D Array Games]

Download the Kings program as a NetBeans project: http://dl.dropbox.com/u/239179/ibcomp/kings/Kings.zip


 * HOMEWORK -**
 * Complete at least ONE of the programming tasks**
 * in the [|notes above]. For example, write the check**
 * that prevents errors when bad numbers (like 5) are typed.**


 * Topics for Internal Assessment - 7 May 2012 **

Discuss proposed topics for the Internal Assessment project.


 * Attendance Problem - 2 May 2012 **

Introduction - http://dl.dropbox.com/u/239179/ibcomp/projects/ProjectStart.pdf More Topics - http://dl.dropbox.com/u/239179/ibcomp/projects/TopicsForMe.html
 * Internal Assessment Start Notes**

Analysis - http://dl.getdropbox.com/u/239179/ibcomp/design/Design.ppt Prototype - http://dl.dropbox.com/u/239179/ibcomp/netbeans/attendance/index.htm
 * Sample Project - Attendance System**


 * More OOP - 30 Apr 2012 **


 * Discussion :** [|Design + OOP]

especially how various PEOPLE use the system.
 * Homework :** Bring ideas about our ATTENDANCE system,

[|Savitch Powerpoint Chapter 5] [|Program Listings for Savitch] OOP Design for Beginners [| Practical UML]
 * Reference (for later):**


 * Encapsulation - 26 Apr 2012 **

Lecture about Encapsulation


 * Brain Game Test - 25 Apr 2012 **


 * Brain Game Methods - 18-19 Apr 2012 **

Read these notes and do the practice methods at the end. http://dl.dropbox.com/u/239179/ibcomp/braingames/OOP1.pdf

We will spend 2 classes writing these methods, and you should also work at home - at least 2 hours between today and next Tuesday. You should share your results with the rest of the class.


 * Plan on a** **written test next Wednesday 25 Apr 2012.**
 * The test will cover all the work we have done on the BrainGames**
 * project, including Object Oriented Programming and these**
 * Methods that the class wrote.**


 * Brain Games with OOP - 16 Apr 2012 **

http://dl.dropbox.com/u/239179/ibcomp/gamesTournament/DividAndConquer.html
 * Summary so far -**

Hear is a first try at an OOP game application: http://dl.dropbox.com/u/239179/ibcomp/braingames/GamesMoney2.zip

Here are some notes about the OOP BrainGames program above. http://dl.dropbox.com/u/239179/ibcomp/braingames/OOP1.pdf


 * Assembling the System - 29-30 Mar 2012 **

Making the SYSTEM work, using the prototypes and ther Accounts.dat file

IDENTIFY urgently needed improvements


 * OOP = Object Oriented Programming - 27 Mar 2012 **

HL - Lecture about OOP

SL+HL - using the ACCOUNTS.DAT file from the shared server.


 * Game Prototypes with Money - 26 Mar 2012 **

Here is our [|**initial system design.**]

We have established that it's possible to share the RandomAccessFile containing the user accounts. Now it's time to try it out with games. We will need a VERY SIMPLE **functional prototype** for each games. This needs to be working by the beginning of class on **Tuesday 27 March.** Then we can test the **feasibility** and **functionality** of the system.

The functional prototype of your game only needs to work a little bit - not completely. For example, if it has questions and answers, it's enough if it can ask 5 specific questions without loading them from a text file. So spend 1 class period and some homework time and bring a very simple working program to class on Tuesday. Then we can start making the log-ins and money work.


 * Sharing a RandomAccessFile - 20-23 Mar 2012 **

[|BrainGames Money Prototype]


 * Shared Disk Drives - 20-21 Mar 2012 **

Setting up **shared** disk drives in Windows.


 * Prototypes and Goals Due - 19 Mar 2012 **


 * Turn in your Prototype** by sending an eMail attachment to the teacher - Dave_Mulkey@fis.edu

Also send one copy of the GOALS completed by the group.


 * Functional Feasibility Prototype**

A feasibility or functional prototype is a **VERY SIMPLE** incomplete version of a program. It should have **some** functioning parts. The main purpose is to test basic ideas to see whether they are likely to function successfully.

Our games are probably simple enough to program. The bigger question is how to share the **ACCOUNT** and **MONEY** files on a LAN server. The simplest way to do this is to use **RandomAccessFiles.**

RandomAccessFile Intro

[|BrainGames Money Prototype]


 * Prototypes - 13 Mar 2012 **

One way to look at a problem is to make a **prototype** of the solution. A prototype shows what will happen when the program is running, one step at a time. It's like telling a story - telling a story of what will appear on the screen when the program runs. This is like a **preview** of a movie or a video game.

Here are a couple examples to illustrate the concept:


 * Preliminary Prototypes** Tic-Tac-Toe Adding Machine

The examples were created in **PowerPoint.**

The first stage of software development (analysis) includes : **investigate, make a prototype and write goals****.**

It will be useful to make prototypes to **map out** the processes that will occur in our Brain Games Tournament program. The point of all this is to:
 * make your **vague, general** ideas more **clear and specific**
 * capture your ideas **on paper** (or in a presentation) so it's easier to **share them**
 * reach **agreement** about how to proceed so the team doesn't waste their time and effort


 * Assignment - due Mon 19 Mar (beginning of class)**


 * 1. from each student a prototype of a possible game**


 * 2. a set of GOALS written by the entire team -**
 * goals for the ENTIRE system (between 10 and 20 goals)**


 * System Diagram - 8-9 Mar 2012 **

More MODULES in a System Diagram. []


 * Homework - read Chapter 7 Software Engineering**

We will look at this in class tomorrow: -- Presentation : [|Software Engineering]


 * Top Down Decomposition - 7 Mar 2012 **

What MODULES (pieces) are needed in the Brain Games Tournament? How can they be grouped/organized so that we can keep track of them?
 * Brainstorm!**

[]

Dividing up the work looks difficult - later


 * System Development - 5 Mar 2012 **


 * What is a computer SYSTEM?**
 * What is System Development?**
 * How is this different than programming?**
 * How can Software Engineering principles improve development?**

We will use the following problem as as example: > **Brain Games Tournament** > The student council has decided (or will soon decide) to run a tournament for students and teachers to compete with each other. The tournament should involve playing some sort of intellectual games. Games need to be relatively quick to play (under 10 minutes if possible), without complex rules - e.g. not like chess. Games should be knowledge based, similar to Trivial Pursuit or Who Wants to Be a Millionnaire. The games could be either multi-player games like Trivial Pursuit, or single player games like Who Wants to Be a Millionnaire. There must be multiple games. The exact nature of the games is open for disussion. The school has agreed that the school's PCs and LAN can be used, but only if the games are "intellectually challenging" (e.g. educational). > > Players need to register to take part. They can play as often as they wish, but each time they play they must donate a small amount of money (under 5 Euros) - these fees will be collected later by the student council and will be spent on various charities. The computer system must only keep track of how much money each student has "pledged" through their various competitions. It is not necessary for the computer system to actually collect real money. > > Players will accumulate points whenever they win a game. At the end of the "season", the most successful players (the top 10) will receive prizes that are to be donated by parents and their companies. For example, first prize might be an Apple MacBook, second prize a cell-phone, 3rd prize a book certificate from Amazon, etc. > > The game system should execute inside the school's LAN. It is not desirable to provide Internet access due to security issues. The school's wireless access will not be used because the behavior of players' personal PCs is not trustworthy. Participants must use PC's in the school's wired LAN. Appropriate software must be installed on all PCs (e.g. the software we are creating). Each player needs a password to protect their account, to prevent hackers from playing games and charging donations to other peoples' accounts. Other security issues and worries must also be investigated. > > The system could be written in any language, but we will use Java. It is desirable that the system can be modified and reused in the future, so it should be well designed, well documented, and as flexible and expandable as possible. The student council wishes to have the possibility of adding new game modules later, so it is important that the system is **modular** and that new games can be added according to a well defined **pattern** or **template.**

The first task will be to make a plan for completing this project within a reasonable time-frame - that includes breaking down the problem into pieces that can be programmed by 6 independent programmers separately, but that will still work together afterward. We will begin planning and designing today.

During this project, the teacher will continue to teach useful system design and programming techniques that improve the development proceess.

[]


 * [HL] Nokia Cell Phone Development - 5 Mar 2012 **

[]
 * Nokia Cell Phone Development**


 * Test - 24 Feb 2012 **

Written Test


 * Where's My Data? - 20-21 Feb 2012 **

- - **Where's my data? - -** Computer Science Illuminated chapter 5
 * Data Storage, Storage Devices and Backups**

[|Hard-disk inside] [|Old Hard-disks, Cards and Tape Drives (1975)]


 * Continue Notebook Program - 15-17 Feb 2012 **

Continue with our Personal Notebook program Here is a working version: [] Run the NOTEBOOK program.

Plan on a written test on **Friday 24 Feb.** This will be done on paper - no computer and no notes. It will cover the topics of **flexibility** and **persistence.**
 * Test Announcement**


 * [HL] How CPUs Work - 15 Feb 2012 **

Structure of the CPU CPU Emulator


 * Notebook Apps - 14 Feb 2012 **

We will create a **Student Notebook** program. This will contain [Buttons] for starting various tasks, including: writing a note, running the calculator, etc.

This may not work on a MacBook, but we will give it a try.

You will need this **method**, which **starts another application:**

code private void calculatorButtonActionPerformed(java.awt.event.ActionEvent evt) { runProgram("calc.exe"); }

private void noteButtonActionPerformed(java.awt.event.ActionEvent evt) { new Note; }

public Process runProgram(String programName) {     Process handle = null; try {        handle = Runtime.getRuntime.exec(programName); }     catch(java.io.IOException ex) {

};     return handle; }

code


 * Date and Time Formats - 8 Feb 2012 **

Read the following notes and write the program described - finish before class tomorrow: Date and Time Formats


 * Flexible Calculator - 7 Feb 2012 **

We will make a very flexible calculator program, including: - dates - money conversion - geometry


 * Flexible Programming - 3 Feb 2012 **
 * Yesterday's Homework - notes aboveand read this Wikipedia article about Cross-Platform compatibility.**

(2) Write a program that calculates the area of a circle. It needs - a text field for the radius - a Button that says [Area of Circle] - a List box with 3 languages that can change the Button text to a different language
 * Homework :**
 * (1) Read** Flexible Programming


 * [HL] Memory - 3 Feb 2012 **

Discussing memory vocabulary and technologies

What kinds of memory and chips are needed in mobile devices? What current and future improvements will empower new devices?


 * Homework : Read this** How Memory Works

Next HL meeting will be about CPUs - no need to read the following yet Structure of the CPU CPU Emulator


 * Software Distribution - 2 Feb 2012 **

You need to turn in your CIA data program tomorrow, 3 Feb, at the beginning of the period.

Today, copy your program onto a PC in the classroom and see whether you can get your program to run in either Linux or Windows. You should read the suggestions in this document : Software Distribution


 * Homework - read the notes above carefully**
 * and read this Wikipedia article about Cross-Platform compatibility.**

Tomorrow we will start discussing **reliability, portability** in our Java programs. Bring **questions** to class about
 * and compatibility,** including how to improve these
 * vocabulary** in the reading above.


 * CIA Factbook Files - 24 Jan 2012 **

Spend one week writing **methods** for the CIA Factbook files. Your program is due on **Wed 1 Feb 2012.**

You should write methods to answer questions like the following, or any similar questions you can think of. > the top 5 countries and the last 5 countries in that file > say population, personal income and life expectancy - > this total gives a "livability index" number > and compare them to see which one is more "livable"
 * What is the population of Germany?
 * What is the population of a country whose name is typed in?
 * Input the name of a file, say "life expectancy", and print
 * Add up the rankings of one country in 3 specific files,
 * Add up the rankings in 3 files for 2 different countries,

Your methods will be similar to these: CIA Sample Methods

Now add some nice GUI elements, like :
 * A list of all the names of all the countries
 * A list of all the names of all the files\
 * A button for each method
 * Make the lists "clickable" so the user doesn't need to type so much


 * [HL] Parity Bits - 24 Jan 2012 **

How Parity Bits Work

Parity Bits Sample Algorithm

bring as many words, acronyms and ideas about RAM as you can find or think of. For example: RAM, DRAM, VRAM ...
 * HOMEWORK -** For the next HL class,


 * Files Test - 23 Jan 2012 **


 * TEST today about File methods**


 * Sample CIA File Methods - 19 Jan 2012 **

Prepare for Monday's written test. CIA Sample Methods


 * CIA Factbook - 18 Jan 2012 **

download a few text files


 * Data Analysis - 17 Jan 2012 **


 * Parsing Strings (cont)**


 * Data Analysis - 16 Jan 2012 **

Write a method that takes one String, which contains number..blanks..name..blanks..population and extracts the number - without the commas.

@https://www.cia.gov/library/publications/the-world-factbook/rankorder/rawdata_2119.txt

Here is the plan:

/ look for double blank space / follow all the blanks spaces / until finding a non-blank character / That's the name. / find another double blank space / follow blanks until non-blank / this the number / remove the commas / convert to a double / return


 * Data Analysis - 12 Jan 2012 **

Finish the practice exercises (program) in the middle of this document: Read these notes about Data Analysis


 * [HL] Checksums - 12 Jan 2012 **

Read about how UPC (bar codes) work.

then decides whether it is valid or not.
 * Homework :** Write a Java method that inputs a bar-code as a String,


 * Data Analysis - 9 Jan 2012 **
 * Back in the 1940's, the first computers were built to do mathematical calculations. At that time, there were no "pocket calculators" - instead, calculating machines were large and mechanical. The computers of the time were huge, occupying a room the size of a library and requiring substantial cooling. Despite the inconvenience and high cost, the possibility of automating long calculations justified building these mammoth machines, as they could perform calculations much faster than mechanical calculators or people with pencils.

In the 1950's, the huge **mainframe** computers become considerably more sophisticated as transistors replaced vacuum tubes. Then storage devices were added - see the disk-drive at the right. With large storage capacity, it became possible to store large collections of data - numerical data. This began the age of **data-processing and data-analysis.**

Data analysis involves examining a large quantity of data and answering questions like: - What are the largest and smallest values? - Which values occur most often? - What is the average value?

Nowadays we have lots of possibilities for storing data. We divide data-storage into three distinct types: - primary or internal storage (RAM, variables, arrays) - secondary or exteral storage (disk-drives, USB sticks, tapes) - remote storage (on servers and web-sites)

Read these notes about Data Analysis || ||
 * Practice - 16 Dec 2011 **

To avoid forgetting all the Java programming you have learned, it would be a good idea to PRACTICE. Any programming you do is good practice. If you don't know what to do, here is a suggestion.


 * Use the Blue Pelican Java book. We have learned pretty much**
 * what is in lessons 2, 3, 4, 5, 6, 7, 8, 9, 11, 13 and 18.**

Read through a lesson. Then look at the exercises at the end. - Choose a question that has code in it. - Predict what the code will print. - Type the code into NetBeans and run it. - If your prediction was incorrect, try to figure out why. - Make some small changes in the code and predict what it will print. - Continue until you think you understand the code. - Repeat with another problem.

You don't need to do all the lessons. But it's good to do some practice a few times a week so that you don't forget everything.


 * Verifying - 14-16 Dec 2011 **


 * Validating** or **Verifying** input by searching an array or a file.

[]


 * [HL] More Crypto - 12 Dec 2011 **

Answers to Password Crypto

Today's Topic: bitwise encryption

Homework : Hash Codes, Encryption Introduction


 * Validating Input Data - 9-12 Dec 2011 **

This Year's Best Robots

[|Validating Data]


 * Writing Text Files with Multiple Fields - 8 Dec 2011 **

Write methods to do the following: > Banana > 1.25 > Chocolate > 0.99 > Donut > 1.19 ....
 * Homework:**
 * 1) WRITE a file containing NAMES and PRICES, like this

2. READ a file that contains NAMES and PRICES, and store them in the two arrays ITEMS and PRICES.

3. DELETE (remove) the LAST item in the list - it's easy: position = position - 1;


 * Writing Text Files with Multiple Fields - 6 Dec 2011 **

If you have trouble writing a correct path name for you data files, you might want to read the following: @http://en.wikipedia.org/wiki/Path_%28computing%29 This is clearly "too much information", but clearly points out a problem associated with writing cross-platform applications.


 * Today :**

> --> Read [|http://people.cis.ksu.edu/~schmidt/PPJv12pdf/ch11V12.pdf] section 11.2 > Banana > 1.25 > Chocolate > 0.99 > Donut > 1.19 > ...... > This data would be contained in two **parallel arrays.**
 * 1) Write a method that prints a double array into a text-file.
 * 1) Write a method that prints NAMES and PRICES into a text-file, like this:
 * 1) Write a corresponding method to READ the data back into two parallel arrays.


 * Loading Data from Text Files - 5 Dec 2011 **

1. Create a text file containing some numbers, like: code 9.99 3.79 5.19 ... code Save it somewhere that you can remember the correct PATH and FILENAME.

2. Write a method that OPENS the file and reads all the data into an array.

3. Write a method that calculates the TOTAL and the AVERAGE of the array.

4. Write a method that adds 10% to all the prices that are below average.


 * All = More Prices - 30 Nov-2 Dec 2011 **

Storing Data in Arrays
 * Homework : Program the first 5 practice problems:**
 * display all the numbers
 * add up all the numbers
 * find the average
 * multiply all prices by 1.05 (inflation)
 * **find the largest number**


 * [HL] - 30 Nov 2011 **

Encryption


 * Data in Arrays - 28-30 Nov 2011 **

Storing Data in Arrays


 * More Lockers - 22 Nov 2011 **

We will have a quiz on **Monday 28 Nov** about arrays. Continue with these notes about lockers.


 * Lockers - 21 Nov 2011 **

Assigning lockers in a school is a similar problem to assigning seats in an airplane. But there are a few small differences. Read these notes about lockers.


 * [HL] Equivalent Circuits - 16 Nov 2011 **


 * NAND Gates #7-10**

You will still need the Circuit Emulator


 * Using Loops with Arrays - 14-18 Nov 2011 **

Introduction to Arrays Airline Seating

Here is code for counting empty seats: code int total = 0;

for(int x=0; x < 10; x = x+1) {           if(seats[x].equals("o")) {              total = total + 1; }

}

output(total + " empty seats"); code

code public int searchForName {       // index variable

String theName = input("What is the name?");

for(int s=0; s < seats.length; s=s+1) {

if(theName.equalsIgnoreCase(seats[s])) {              return s;            }

}

return -1;

} code


 * For Loops in Java - 10 Nov 2011 **

Read chapter 11 in BluePelican Java (read pages 11-1 to 11-3) On page 11-4, do problems 1,2,3,4,5,6. In each case, predict what you think the code should print. Then type it into a Netbeans program and check your prediction. If you were wrong, discuss it with another student and find out what was wrong in your thinking.

Write a loop that ADDS UP the following: 1+2+4+8+16+32+....+1024+... until it reaches the largest value that is still smaller than 1 million.
 * Homework:**

Bring questions to class on Monday.


 * More Questions? - 3 Nov 2011 **

More questions before the test on Tuesday? [|Case Study Questions and Links]
 * [HL and SL]**

RAM is Dynamic RAM (DRAM), meaning it loses it's contents easily and must be **refreshed** continually. Cache is STATIC RAM (SRAM). It does not lose it's contents as long as the power is still on.
 * [HL]**
 * What is the difference between Cache and RAM?**

SRAM is more expensive because it uses 6 transistors per bit rather than 1 transistor and 1 capacitor per bit. That means DRAM can achieve much higher densities, so much more memory capacity on the same size chip - hence DRAM is cheaper than SRAM. SRAM requires no refresh mechanism.

SRAM can function faster because it never needs to execute refresh operations. Read more details here if you wish (optional).


 * Homework from last time: NAND Gates #6**

This page shows how **transistors** are used to actually build logic gates in an integrated circuit: @http://230nsc1.phy-astr.gsu.edu/hbase/Electronic/trangate.html
 * NAND Technology -**


 * What do transistors look like and how do they work?**
 * This stuff is optional - this is not an electronics class.**

If you want to know why NAND technology is better than NOR technology for USB sticks, here is more information than you will ever need: http://139.138.48.19/pdf/NAND/MSystems/MSystems_NOR_vs_NAND.pdf (optional)

Here is a video about **fabrication** of Integrated Circuits, with some pictures of what transistors actually look like. @http://www.youtube.com/watch?v=35jWSQXku74&feature=related

Here is a look at 3D transistor technology: @http://www.youtube.com/watch?v=_zldnUY0t1M

How a MOSFET transistor works: @http://www.youtube.com/watch?v=Te5YYVZiOKs&feature=related

TTL = Transistor-Transistor-Logic - how the electricity flows around (TMI): @http://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic

To really understand the stuff above, you need some basic understanding of how electricity moves around in circuits - e.g. why are there resistors all over the place. Here is a good explanation of basic electricity: @http://www.seattlerobotics.org/encoder/mar97/basics.html


 * Self-study and Questions - 1-2 Nov 2011 **


 * TEST ALERT - prepare for a TEST on Tues 8 Nov.**

Smartphone Security - [|http://www.dailymotion.com/video/xkq1kq_android-malware-spike-run-your-pc-when-the-power-is-out-hdmi-cable-myths-4g-vs-wifi-stream-your-wedd_tech#rel-page-6]

Students' View on Smartphone Use []

Maybe you can find a better video about Android Malware or other Mobile Phone Security.

[|Case Study Questions and Links]


 * Processing - 28 Oct 2011 **

code "The iPhone 4 includes a panel laminated on the glass which uses electrical fields to sense the user’s touch. It has a multi-touch feature that can register simultaneous touches. The user can bring up different information or menus by actions such as swiping, tapping and pinching. Information is displayed on the panel using a “Retina display”. This display contains a high pixel density (326 pixels per inch) that provides clear, sharp images." //**IB Case Study:Smartphones, p. 7**// code
 * Homework: Find out what the following means and how it works:**


 * Memory - 27 Oct 2011 **

Memory - RAM, ROM, Cache : @http://www.pctechguide.com/computer-memory Flash Memory : @http://www.pctechguide.com/computer-memory/flash-memory Refer to page 4 in the Case Study


 * Smart Phone Case Study (cont) - 26 Oct 2011 **

> to the entire class, including the teacher. Figure out > a way to do this. > "normal" methods as well as "exotic" methods
 * Homework:**
 * 1) You must distribute a copy of your homework (yesterday)
 * 1) Think about all the ways that information CAN be distributed -

Case Study Vocabulary


 * Smart Phone Case Study (cont) - 24 Oct 2011 **

[|Smart Phone Case Study]


 * [HL] NAND Gates - 24 Oct 2011 **

NAND gates - @http://dl.dropbox.com/u/239179/ibcomp/circuits/nandgates.pdf


 * Homework : Question #6**

You will still need the Circuit Emulator


 * Smart Phone Case Study - 20 Oct 2011 **

[|Smart Phone Case Study]

1. What are the **specifications** for a cheap tablet available in Germany? [| http://dl.dropbox.com/u/239179/ibcomp/tablets/cheapTablet.pdf]
 * Cheap Tablets - 20 Oct 2011 **

2. Start making a list of **hardware and system vocabulary** connected to the Case Study.


 * Cheap Tablets and Hardware Basics - 18 Oct 2011 **

How many students will be in class on Thursday?


 * World's Cheapest Tablet PC - Made in India**


 * Specifications for the Aakash Tablet**


 * Homework :** **read the case study** : [|Mobile Phone Case Study]


 * Fast Food Cash Register - 12-17 Oct 2011 **


 * World's Cheapest Tablet PC - Made in India**


 * Continue working on Fast Food Cash Register.**
 * Due at the beginning of class on Tuesday 18 Oct.**


 * Continue Fast Food Cash Register - 30 Sep 2011 **

[Optional] How to write text into a LOG file code import java.io.*;   // at top of program

.     ..

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

try {       PrintWriter info = new PrintWriter(               new FileWriter("//home/davemulkey/food.txt",true)          ); for(int x=0; x < list1.getItemCount; x = x+1 ) {           info.println(list1.getItem(x)); }       info.println("-"); info.close; }     catch(Exception ex) {  System.out.println("error = " + ex.toString); } } code


 * If.. Decisions - 26-29 Sep 2011 **

Fast Food Cash Register


 * String Example Answers - 23 Sep 2011 **

String Examples Program .zip

String Examples Answers

Be prepared for an OPEN NOTES QUIZ on Monday. You should ensure that you UNDERSTAND all the commands in the String Examples Answers (above). You should print out the answers, write notes on the page about the important commands, and bring these notes with you to use during the quiz. After that, keep those notes as a REFERENCE in your notebook, so you can look back at this sample code to see how to write future programs.
 * Quiz (15 minutes) on Monday 26 Sep 2011**


 * [HL] Logic Gates and Circuits - 20 Sep 2011 **

Circuit Emulator

Basic Circuits


 * EXTRA** : Gamers Solve Retrovirus Problem

@http://www.sciencedaily.com/releases/2008/05/080508122520.htm

@http://www.sciencedaily.com/releases/2011/09/110918144955.htm


 * More Strings - 20 Sep 2011 **

Continue StringExamples work.


 * More Strings - 15-19 Sep 2011 **

Here are some notes about Strings and String methods. @http://dl.dropbox.com/u/239179/ibcomp/Strings/StringNotes.html

And here some notes about **if** commands involving Strings. @http://dl.dropbox.com/u/239179/ibcomp/Strings/IfExamples.html

And here are a couple practice programming examples: @http://dl.dropbox.com/u/239179/ibcomp/Strings/StringExamples.html


 * Strings - Wed 14 Sep 2011 **


 * Using STRING variables for words and other non-numeric data**


 * Homework -** read Savitch 1.3 about Strings


 * Test on Loops and Numbers - Tue 13 Sep 2011 **


 * More Funny Symbols and Loops - Fri 9 Sep 2011 **

[SL & HL] .. Lots more Loops

code More Loops

// Trace each loop (that means predict what it will print) // After making your prediction ON PAPER, you may wish // to run it in NetBeans and check your prediction.

for(int x = 0; x < 10; x = x+2) {  System.out.println(x); }

for(int y = 1; y < 10; y = y+2) {  System.out.println(y); }

for(double c = 0.1; c < 10; c = c+0.1) {  System.out.println(c); }

int total = 0; for(int n = 5; n <= 20; n = n+5) {  total = total + n;   System.out.println(total); }

double sum = 0; for(double d = 10; d != 0; d = d-1) {  sum = sum + n;   System.out.println(total); }

int k = 1000; for(int p = 1; p <= 5; p++) {  System.out.println(k); k = k / 2; }

for(int m = 100; m != 0; m = m - 7) {  System.out.println(m); }

// Now practice writing your own loops to do the following: // //  - count 3, 6, 9, ... 99 //  - count 1, 2, 4, 8, 16, ... 1024 //  - add up 1+2+4+8+...+512 //  - add up 11+12+13+14...+19 //  - print all the perfect squares up to 1000 :  1, 4 , 9 , 16 , 25 ,... 900, 961 //  - add up 1/2 + 1/3 + 1/4 + 1/5 + ... until the total is greater than 5 //     Does that actually happen, or is this an infinite loop? // // Write your solutions in NetBeans and test them.

code

[HL] :
code Logic operations : 12 & 6 = 4 ,  12 | 6 = 14  ,  12 ^ 6 = 10  ,  12 % 6 = 0  ???

Special characters : \u221a  ,   \u00b2   ,   \n  ,  \t  ,  \q  ,  \\ code You can see lots of mathematical Unicode symbols in tables like this: http://www.ssec.wisc.edu/~tomw/java/unicode.html#x2200

Try reading this : [|http://unicode.org/standard/WhatIsUnicode.htm]

What does it mean?

 * x = x+1
 * x = x / 2
 * x++
 * x--
 * x += 5
 * x = 1.05 * x
 * x = x + 0.5*x

**Homework Postponed: Read** BluePelican Java Chapter 11 and do problems 1-6 ( or quit after 30 minutes.)

Loops! - Mon 5 Sep 2011
**## Plan on having a TEST on Friday 9 Sept pd 6 ##**

The teacher will explain how LOOPS can be used to print table of values for math problems. Here are some sample calculations with loops. If you want to read about loops, try these: @http://math.hws.edu/javanotes/c3/s4.html BluePelican Java Chapter 11

Table of Values - Mon 30 Aug 2011
Be sure to get a copy of the class CD today. Take it home and leave it there.

Today's assignment - creating a **Table of Values** for a calculation, like the following:

Searching for the smallest value of Y = (x-4)(4x+1) -4 -3 -2 -1 0 1 2 3 4 5 ||= 171 120 77 42 15 -4 -15 -18 -13 0 21 || code System.out.println("X \t Y"); double x, y;
 * = X ||= ... Y = (x-4)(4x + 1) ||
 * = -5

x = inputDouble("X"); y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

x = x + 1; y = (x-4)*(4*x+1); System.out.println(x + "\t" + y);

code

[HL] Binary Decimal Storage - Mon 30 Aug 2011
[]

More Calculations with I/O - Mon 29 Aug 2011

 * Class meets in 290 (Mr Shoebottom's room) today and tomorrow **

Today's assignment

Remember that HL students meet TWICE tomorrow: Pd 2 and Pd 6

More Calculations with I/O - Fri 26 Aug 2011
Math problems with input and output commands.

[|IBIO Functions]

Calculation ERRORS - Tue 22 Aug 2011
Computers do lots of calculations - millions or more per second. Unfortunately, they sometimes make mistakes. We call these **ERRORS**. They are not actually caused by computer "mistakes", because the computer is following programming that a human being wrote. And computers do follow that programming **exactly**. So if there is a mistake, it came from a human beings. Computers are **perfectly RELIABLE** (well, maybe 99.999%).

We will look at some common **ERRORS** that occur in computer programs - especially Java programs. For example, this command does NOT print what you expect.


 * System.out.println(0.1 + 0.2 + 0.3);**

Here is a practice assignment, doing calculations.

Calculations - Mon 21 Aug 2011
Discuss the reading from last time

Calculations - 19 Aug 2011
**Read this and do the exercises** - the teacher will help you get started.

**Homework** : Read Eck section 2.2.

First Day - 17 Aug 2011
**Today's Assignment - Jokes Program**

**Introduction to IB Computer Science** (read as time permits)

IB Computer Science is a 2-year course. The first year deals mainly with **programming in Java**. The second year covers **hardware and system concepts**. During the second year students will create a large programming project to solve a real-world problem (the Internal Assessment dossier). At the end of the second year, students take two written examinations, approximately 2 hours each. The dossier and exams each contribute 1/3 of the final IB mark.

Students learn to write Java programs efficiently and quickly, enabling them to complete the Internal Assessment project (dossier) successfully. They also learn to write clear explanations about computer systems, hardware and software, using correct technical vocabulary, enabling them to successfully answer written exam questions.

The teacher will make every effort to present new concepts clearly and completely, as well as allowing ample class time for practice and discussion. Students must make an equally conscientious effort to learn, understand and remember the topics. Students are expected to learn **as much as possible at all times** and to:
 * attend classes
 * participate actively and energetically in all class activities
 * read notes and practice programming outside class time (e.g. homework)
 * **ask questions** and **seek help** whenever they are having trouble with the work

Normally students will have a working PC at home, where they can write and debug Java programs. In the unusual circumstance that their PC is broken, students need to plan on spending extra time at school, outside class time, to complete programming assignments. Some class time is devoted to writing programs, but this is not sufficient to completely finish assignments.

**More Notes for This Course**
 * 2-year Teaching Plan + Vocabulary
 * Good Habits for Success
 * General Comments about How to Study

[|Illuminated]