IB Computer Science year 1 - Frankfurt International School - Dave_Mulkey@fis.edu - 2016-17
Links :   Basic Java LessonsLewis+Loftus Java 7  Java Tutorial  Java Video Tutor  Pseudocode   Wu Java Textbook
            IBCS Course Guide      Notes and Review Page (for 2017 exams)    Internal Assessment Project Notes
                Vocabulary   CS-Dictionary  HowStuffWorks - Computers   Java Algorithm Practice
 Next graded assignment :  Functional Prototype - 24 Aug 2017 at 18:00

Starting Functional Prototype - 19 June 2017

Functional Prototype

Notes about Functional Prototype

We will work on the functional prototype assignment
during class this week.  Students should ask questions and get help

if they are unsure what is required.  

Here are some examples:

Here is a VISUAL prototype for TicTacToe.

Here is a FUNCTIONAL prototype for TicTacToe

Here is a VISUAL prototype for adding numbers 

Here is a FUNCTIONAL prototype for adding numbers

The assignment is due on 24 Aug 2017.

Discussing Case Study - 14 June 2017

Autonomous Taxi in Berlin


Ethical Dilemma Video

Case Study - 13 June 2017


More HL Questions - 26 May 2017

Here are some HL questions, emphasizing what we studied this year:

Study for Final Exam - 23-26 May 2017

Java Algorithm Practice

Last Year's Final Exam

Answers to Last Year's Final Exam

Read this Blog

Continue with Visual Prototypes - 19 May 2017

You may continue working on your Visual Prototype today.
Next week we will be reviewing for the final exam,
so you won't be working on the Visual Prototype during class.
If you have questions or uncertainties, get help today.

Visual Prototypes - 17 May 2017

First of all, the planned test for next Tuesday is CANCELLED.
We are too close the final exams, so we don't need another test.

Secondly, due to cancelled class on Thursday, and ISSTs,
the Visual Prototype will be due on Monday 29 May at 18:00
(instead of 24 May).

We will spend today working on the Visual Prototype,
and maybe one day next week.

       Starting Simple    Big Tic Tac Toe Prototype  

[HL] Reviewing for Final Exam - 16 May 2017

Why do malware programs, like WannaCry,
only affect Windows OS machines?  What is a patch, anyway?

Do Macs get viruses?

Mac Ransomware

=== HOMEWORK ===

Watch this video.

Video about Operating Systems

Review for the final exam by reading through the notes on this blog -
for HL, search for HL in the blog.  There will be HL
questions in the final exam.

Topic 1 - 15 May 2017

topic 1.2 notes

Practice with User Stories - 11-12 May 2017

The teacher will help individual students to get started
writing User Stories.

User Centered Design and Usability - 9 May 2017

We will put NetBeans aside for a few days.

Today, we will watch some of this video.

Also watch this video.

We will also read some of these syllabus notes : topic 1.2.

And we will again discuss the concept of User Stories,
after watching this video.

Tabbed Interface and Tables - 8 May 2017

We will continue working on the Tabs program, and add a JTable. 

*** Client Interview Notes *****************************************

Before 18:00 today, in Haiku upload your notes about your Client Interview.

Normally this would be a .PDF file, but you may upload an MS Word document
if you prefer.


Tabbed Interface - 5 May 2017

*** REMINDER - your Client Interview Notes are due on Monday   ***
*** turned in to Haiku before 18:00.  You may wish to look at      ***
*** this example from an IBO Sample project (look at Appendix). ***
*** Yours does NOT need to look EXACTLY like the example, but  ***
*** it should include actual notes from your interview with your   ***
*** client and should be 1-2 pages in length.  This assignment     ***
*** is just a project check - no grade will be assigned, but           ***
*** the teacher may make comments.                                        ***

The teacher will demonstrate how to create a Tabbed interface.

Continue with this NetBeans project and open the TABS class.

In each Tab, add another copy of the same control that is already there.
For example a second Password field on the first tab,
and another set of Spinners to input another PIN number.

Then add one more Tab.  In this new Tab,
add controls to create a program that
inputs a student's grades on various tests
in a class.  Then add a button that adds up
the grades and divides by the number of grades
to calculate the average grade.

[HL]Stacks and Queues - 4 May 2017

You can read about STACKS and QUEUES in Data Structures .

Here is code for a STACK List - the list is called list1.

   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
      String item = input("New Item");

   private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
      int count = list1.getItemCount();
      String item = list1.getItem(count-1);

Create a Java class that implements the Stack shown above.

If you need it, here is the code for the IBIO input and output commands:

Then add a Queue, with [Enqueue] and [Dequeue] buttons.
The Dequeue button must always remove the first item in the list,
rather than removing the last item in the list.

Finally, add appropriate ERROR handling code, so that when
the Stack or Queue is empty, then trying to remove an item
generates a warning like [The Stack is empty],
rather than causing a BIG RED EXCEPTION.
You can do this by checking list1.getItemCount().
If it is zero, then output a warning message.
If not, perform the expected operation.

Saving Data Files -3 May 2017

Download this NetBeans project and open the DataFile class.

Try the following exercises:
- Load data.txt, change some of the text,
  Save the result, then close the program and
  run it again and Load data.txt to check whether
   if kept your changes.

- Find out how to type a file path+filename to save and
   load from the Desktop.

- Change the program to maintain a LOG of who uses the program
   and when they use it.  That means it needs to do the following:
   -  at the start, input the user's name
   -  use new Date() to get the current date and time
   -  LOAD the old LOG.TXT file
   -  use .getText() to get all the data
   -  Append the user name and date to the end, including "\n"
      to put this on a new line
   -  Save the result in LOG.TXT
   -  This should all happen automatically when the program starts.
      The LOG.TXT file should get longer each time the program runs.

- Load the file wordlist.txt.  This is list of 45000 English words.
   Notice that they are NOT in alphabetical order.
   Discuss whether that matters.  For example, if you insert "hilfe"
   at the end of the list, and the [Search] button finds it,
    is that enough?  If not, you need to use .split("\n") to change
    the huge String into an array, then sort the array, then
    concatenate all the separate entries back into a single String,
    and save the result back in the file.

Software Design - Investigation and Design - 2 May 2017

Read these notes:

We will continue discussing topic 1.2.

We will discuss how to make a Java program that loads data, presents it,
changes it and then saves it.

Download this NetBeans project and open the DataFile class.

Before tomorrow, submit your project proposal.
Fill in this information and upload to Haiku:

IA Proposal for Topic and Client

Fill out the following and upload it into Haiku.
This will not be graded - it is simply a progress check.


Student Name:_______________________________

Client Name : ________________________________

Proposed Topic/Problem - describe your topic/problem
in a few sentences, including at least one suggestion for
how your program will benefit the user:

Opening Other Applications - 28 Apr 2017

We will continue discussing topic 1.2

Remember that on Tuesday 2 May (next class)
you must SUBMIT the name of your CLIENT (intended user)
and a brief description of the TOPIC/PROBLEM you will be doing.
You will need to WRITE THIS ON PAPER during class on Tuesday,
following the instructions you receive on that day.

Download this NetBeans application.

You should add more buttons in each section -
more picture buttons, more web-site buttons,
and more application buttons.  Do as many as
you can in the time available, but for sure
at least 2 in each section.

Usability - topic 1.2.12 - 25 Apr 2017

We will discuss USABILITY and USER-INTERFACE design,
using NetBeans to help with the actual implementation.

==  NetBeans Practice ==

Create the attendance program shown below,
using the code below.


The program below contains:
  - a Swing JLabel
  - an AWT Choice
  - a Swing JTextField
  - 6 Swing JRadioButtons, grouped together
     in a Swing ButtonGroup
  - a Swing JButton
  - an AWT List

    public Teacher2() {

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {             
        String s = jTextField1.getText();
        String t = choice1.getSelectedItem();
        String p = period;
        String info = s + " | " + t + " | " + p;

    String period = "";
    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
         period = "1";

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        period = "2";

    private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) { 
       period = "3"; 

    private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) { 
       period = "4";

    private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) {     
       period = "5";

    private void jRadioButton6ActionPerformed(java.awt.event.ActionEvent evt) {      
       period = "6";

Starting the Internal Assessment Project - 24 Apr 2017

Internal Assessment Project Notes

Choosing a Topic (from last week)

Example Design Overview - Attendance System

Software Design Principles

*** HOMEWORK ***
We will start using NetBeans for writing Java programs.
You need to install it and bring it to class tomorrow
in working condition.  You can download it at:
Choose the Java SE version (smallest download).
== OR ==
to download NetBeans WITH the Java JDK.
== OR ==
borrow a USB stick from the teacher.

[HL] Some Software Engineering Videos - 7 Apr 2017

User Stories and Acceptance Tests

What is Software Engineering Anyway?

Here are some more videos about User Centered Design:

How Designers Destroyed the World

IA Project Overview : Getting Started - 4-6 Apr 2017

We will look at Starting the IB Comp Sci IA Project - Choosing a Topic

Look at the first section in Software Design Principles

and at PAGE 4 in Guidance Notes (from old syllabus - ignore details)

Algorithm Videos Presentation - 31 Mar 2017

Some more Resources - 24 Mar 2017



Group 4 Project - Algorithms - 21 Mar - 31 Mar 2017

Read the assignment here.

You will present your finished video to the class on Friday 31 Mar.

Test about 2D Arrays - 20 Mar 2017

Do your test about 2D arrays.

*** Homework ***

Read this news article about Algorithms:

Magic Squares - 17 Mar 2017

Here is a video about magic squares:

Now download this Java program
and do the practice exercises listed at the bottom:

public class MagicSquare
    public static void main(String[] args)
        new MagicSquare();   

    int[][] nums = {
            {3,5,7,0} ,
            {4,2,9,0} ,
            {6,1,8,0} ,

    public MagicSquare()

    public void sums()
        nums[0][3] = nums[0][0]+nums[0][1]+nums[0][2];
        nums[1][3] = nums[1][0]+nums[1][1]+nums[1][2];
        nums[2][3] = nums[2][0]+nums[2][1]+nums[2][2];

    public void checkRows()
        if(nums[0][3]==nums[1][3] && nums[1][3]==nums[2][3])
        {  System.out.println("ROWS SUCCESS"); }
        {  System.out.println("ROWS failure"); }

    public void checkCols()
        if(nums[3][0]==nums[3][1] && nums[3][1]==nums[3][2])
        {  System.out.println("COLS SUCCESS"); }
        {  System.out.println("COLS failure"); }

/**** Magic Square ***************
A Magic Square is a square 2D array.
All ROWS and all COLUMNS and both DIAGONALS
must add up to the same number.

In the example above, all the rows add up equal.
But the column totals are not equal.
The method that checks the columns is NOT CORRECT,
because the SUMS method did not actually add up
the columns.  So the column totals are all 0,
which appears to be the same for all 3.
But this is wrong, of course.

There are lots of improvements needed here.

(0) Write a method that prints out the entire NUMS
    array, AFTER the SUMS method has run.  So it
    will look like this:

         3  5  7  15
         4  2  9  15
         6  1  8  15
         0  0  0   0

(1) Fix the SUMS method so that it adds up the columns.

(2) Change the program so that it checks everything
    correctly: rows, columns and diagonals.
(3) Fix the NUMS array so that it is actually correct.

(4) Change the program so that the SUMS method
    uses LOOPS to add up all rows and all columns.
(5) EXPAND the program to do a 4x4 magic square,
    containing the numbers 1,2...16 .  This is quite
    a famous problem - you will find correct
    number arrangements online.  You should try to
    do all the adding up (SUMS) with loops.

Extra Credit (only if you are interested and have time)

The interesting part of a Magic Square program is that
the program actually SOLVES the Magic Square - that means
it puts the numbers in the correct positions.
You will find solutions for number placement online.


Extra Credit : https://www.youtube.com/watch?v=QSmPrDSVLEU

[HL] Binary Search Trees - 16 Mar 2017

This is a video about Binary Search Trees:

Here is a program that demonstrates how a Binary Search Tree functions.


-- TreeArrays --
This programs demonstrates how a tree can be stored in arrays.
Position 0 in the arrays is not used - a 0 entry indicates null.
Answer the following questions:
(1) Without running the program, predict what it will print.
(2) Without running the program, predict what would be printed
if root were changed to 6.
(3) Predict what would be printed if root were changed to 1.
(4) Run the program and check your answers to 1,2, and 3.
(5) Make a data array with names that are NOT in
    alphabetical order, then change the POINTERS
    so the program prints the names in alphabetical order.

public class TreeArrays
    public static void main(String[] args)
    { new TreeArrays();}

    int root = 4;
    String[] data  = {"","Arnie","Bob","Carla","Don","Ed","Fern","Gene"};
    int[]  left  = { 0 , 0 , 1 , 0 , 2 , 0 , 5 , 0 };
    int[]  right = { 0 , 0 , 3 , 0 , 6 , 0 , 7 , 0 };

    public TreeArrays()
    {  traverse(root);

    public void traverse(int pos)
        String word = data[pos];
        int leftPointer = left[pos];
        int rightPointer = right[pos];

        {  traverse(leftPointer); }


        {  traverse(rightPointer); }



Battleship with Sensors - 15 Mar 2017

When you attack a square, it might contain 0.  If so, the program
should tell you the SUM of all the squares AROUND that square (like MineSweeper).
Be careful that errors do not occur at the edge of the board.
Write the code for this - the teacher will get you started.

Battleship - Simplified Version - 13-14 Mar 2017

Download this program and do the practice exercises at the end.

*** Test Announcement *******
We will have a written test about 2D arrays
on Monday 20 March.

Kino Seating - 9 Mar 2017

We will start with this Kino Seating program.

There are lots of improvements needed.
Today, we will work together to make some improvements, for example:

(1)  It should be possible to reserve 2 seats without needing
      to click twice or type the name twice.

(2) It should NOT be possible to replace one name with another.
      Once a seat is reserved, it is protected.

(3)  SEARCH for a name - later, after lots of reservations
       have happened, then search for which seat
       belongs to a specific name.

(4)  Count the number of empty seats.

... etc ...

More on Monday.

Last Kings Day - 8 Mar 2017

Start with this finished program.

We will discuss some/all of the following:

(1) How can we make the game more flexible, allowing larger boards?
     If we do this, will the computer's "perfect strategy" still work?
     Will the computer at least continue to play legally?

(2) How can we convert this program to a GUI version,
      where the players can just click on squares to play,
       rather than typing in 2D array coordinates?

(3) Discuss : is this an example of Artificial Intelligence?

[HL] Trees - 6 Mar 2017

Here are some introductory notes about TREES.

Here is a short video with a brief introduction to the MINI-MAX evaluation algorithm.

AI Kings - Playing Against the Computer - 3 Mar 2017

Mr Mulkey is out sick again today - hopefully back at school on Monday.

Start with this program:

Then work together with another student to add some of the following improvements:

(1)  The game should end automatically when the board is full.
       To do this, the program needs a method that:
       - scans through all the squares on the board
       - checks whether each square is FREE and COUNTS all the free squares
       - if the resulting count is zero, then the game is over

(2)  Change the COMPUTERMOVE method so that:
      - it always checks the middle square first.
        If the middle square is FREE, it chooses that square.
        Otherwise, it chooses a RANDOM square, by choosing a random ROW
        between 0 and 4 and a random COLumn between 0 and 4.
        If that spot is not FREE, it tries again, choosing random squares
        until it finds a FREE square.

(3)  Make a SMART COMPUTERMOVE method.  Assuming it plays first, in the middle,
       it always chooses the square that is symmetrically opposite from
       the human's move.  For example, if the human chooses 30, then the
       computer must choose 14.  That means it must "remember"
       what the player's last move was.

Even Better Kings - 2 Mar 2017

Here is a copy of the Kings program that correctly rejects
illegal moves.


(1) Download the program.  Run it and check that it correctly rejects
     illegal moves, including at the edges of the board and off the board
     if the player types 88.

(2) Try changing the program to use a 6x6 board.
      Does it still correctly reject illegal moves?

Now it is time to implement a PERFECT strategy for winning.
It goes like this:

- choose to play on a 5x5 board (or any other odd-numbers size)
- choose to play first
- play in the center square
- now wherever the other player moves, you must play
   in the exact symmetric location - symmetric through the center square.
- This must win, because you will always make the last move.

For example:

-  22
-  00
-  44
-  41
-  03
-  20
-  24

Now the board is full and the first player is the winner.

There are two tricky parts here:
(.1) The game should end automatically when the board is full
(2) How can the COMPUTER correctly calculate the position
     for the next move, base on the other player's move
     (assuming the computer played first)?

Spend some time talking with other students about how
these two things can be added to the program,
especially how can we make the computer play automatically

Better Kings Program - 1 Mar 2017

Mr Mulkey is at home with the flu today.
He will hopefully return on Thursday.

Download this program.

Before allowing a move, the FREE method checks
whether it is a legal move or not.  It does not work perfectly.
It needs to check 8 squares around the intended move,
as well as the square itself.  You should try to improve
the FREE method to be as good as possible.
You will probably get ERRORS when you try to do this,
Make the program as good as you can and we will
discuss (and fix) the problems tomorrow.

If you finish the FREE method early, you can continue
searching for a "winning strategy".  If you find a solution
for the 5x5 board, then search for a solution for a 6x6 board.

2D Arrays and Kings Puzzle - 27 Feb 2017

Download this program
and do the practice exercises at the end of the program.

Growth and Learning in Computers - 17 Feb 2017

We are going to watch this video (or at least part of it).
We will discuss this tomorrow during class.

- How can machines use LISTS to store data and learn?
- How much data does a "learning" computer need to absorb and store?
- How many words do you know?
- How can we write a Java program that "learns"?
- How could a computer "learn" a foreign language?

Then we will  watch this video , at least part of it.

Test on Topic 2 - 16 Feb 2017

[HL] Busses, Transmission Speed - 15 Feb 2017

==  We will do the rest next class (no homework) ==

Internet of Things Video (4 min)

Moore's Law

History of Moore's Law - reduced sizes

Apple 1 Motherboard 1978 (picture)

486 Motherboard 1990 (picture)

Baby AT Motherboard

SOC Motherboard (system on a chip)

Smartphone Motherboard

Notes with Pictures

Topic 6 - System Resources 

Topic 2 - Topics and Vocabulary - 14 Feb 2017

Topic 2

Wednesday is an HL class.

The test on Topic 2 will be on Thursday -
a written test, no computers.

Test Postponed - 13 Feb 2017

Today's planned test is postponed until Thursday 16 Feb.
(or we can discuss a better day on Monday).

Today we will continue discussing Machine Language and Binary.

Binary Addition with Gates (video)

Binary Practice

Machine Language - 10 Feb 2017

PDP 8 Video

Machine Language Emulator

Binary Numbers - 8-9 Feb 2017


Define the terms: bit, byte, binary, denary/decimal, hexadecimal.


bit = true/false , 1/0 =  BInary digiT

Byte = 8 bits = 0 … 255

binary = number system Base 2, using bits

denary/decimal = base 10

hexadecimal = base 16 using  0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Practice Questions


Outline the way in which data is represented in the computer.


To include strings, integers, characters and colours. This should include considering the space taken by data, for instance the relation between the hexadecimal representation of colours and the number of colours available.

TOK, INT Does binary represent an example of a lingua franca?

S/E, INT Comparing the number of characters needed in the Latin alphabet with those in Arabic and Asian languages to understand the need for Unicode.

numbers = stored in binary, usually displayed in hexadecimal

characters = stored in ASCII (8 bits) or UNICODE (16 bits)

colours = 24 bit = True Color = Red/Green/Blue 1 Byte each

    2^24 = 16 million colors

Boolean Algebra - 7 Feb 2017


The circuit above contains an AND gate, an OR gate, and a NAND gate.

Make a truth table for the circuit.

Then state which single logic gate performs the same function.


NAND Gates and More Questions (4-7,10)

More Circuits - 6 Feb 2017

Circuit Gates Emulator

Practice exercises 

NAND Gates and More Questions

[HL]More Advanced Components - 3 Feb 2017

These are things you should SEE - you do not need to KNOW them.

Types of OS Fast As Possible Video (5 min)

Robotics Operating System Video (first 14 min)

Dual OS for Drones Video (5 min)

How Tesla's Self-Driving Car Works Video (5 min)

V2V May Save Your Life Video (3 min)

Internet of Things Video (4 min)

Getting Started with Arduino Video (11 min)

Low Budget Burglar Alarm Video (7 min)

Circuits - 2 Feb 2017


Construct a logic diagram using AND, OR, NOT, NAND, NOR and XOR gates.


Problems will be limited to an output dependent on no more than three inputs.

The gate should be written as a circle with the name of the gate inside it. For example:

logic gate

LINK Thinking logically, connecting computational thinking and program design, introduction to programming.

Not enough space here

Logic Gates Intro Video

Circuit Gates Emulator

Practice exercises  

NAND Gates and More Questions

Operating Systems - 1 Feb 2017


OS As Fast As Possible

Types of OS Fast As Possible

Operating Systems - 31 Jan 2017


IB Topic 2 - Computer Organization - 25-28 Jan 2017

We will spend a couple (maybe 3) weeks discussing Topic 2.

   Topic 2 - Computer Organization      Version of Topic 2 with Vocabulary Markup     Systems and Hardware Pictures 

== Cross Platform ==

What software runs EVERYWHERE?
How can we MAKE software run everywhere?
When it does work, how do we move software around?
Should I buy a Chromebook?
-- Vocabulary --
Cross-Platform (and Platform)
Open Source
Operating System
Look and Feel
Chrome, Android, iOS, Windows, Mac OSX, Linux
ARM and RISC processors
SoC = System on a Chip
ASIC = Application Specific Integrated Circuit
... more to come ...

== Reference Articles (optional, read as needed)

Cross-Platform Apps

Java for Cross Platform Mobile

Here is an explanation of how to enable Java Applets in various browsers:

Here is a brief explanation of "cross platform" software.

Notes about porting Java from Mac to other platforms

Java Issues

Naughty Twins - Java and Flash

Java Security Issues

Google Inbox for Mobile Apps

Why Mobile Apps are Slow

Running Android Apps on other Platforms

Switch Now - it's Easy

Switch to a Tablet - you don't need a PC

CPU Compatibility
http://www.howtogeek.com/180225/arm-vs.-intel-what-it-means-for-windows-chromebook-and-android-software-compatibility/ (ARM vs Atom)
https://kb.wisc.edu/page.php?id=4927 (Intel, AMD, Arm)
http://www.tomshardware.com/t/cpus/ (Too Much Info about CPUs)

[HL] Busses, Transmission Speed - 24 Jan 2017

==  We will do the rest next class (no homework) ==

What is a BUS? Video

  Notes with Pictures
Topic 6 - System Resources   

More with Text Files - 19-20 Jan 2017

(1) Show your 5 question program to the teacher.

(2) We will change the program to save results into a text file.

Here is the "finished" program, including saving results.

LinkedList with Text Files - 17 Jan 2017


Using LinkedList - 16 Jan 2017

Download this Questions Program that uses a LinkedList
Do the practice exercises at the end of the Questions class.

*** Test on Monday 23 Jan **********************
We will have a test on Monday 23 Jan about:
- storing data in a class/object like the Question class
- storing Objects in an array
- storing Objects in a LinkedList
- storing data in files on the hard-disk

Saving and Loading - 13 Jan 2017

Download this new copy of the Questions program.

This program can SAVE all the questions in a disk file,
and then later load them back in when the program runs again.

(1) Download the program.  Click the [Add 3] button.
     Then click the [Save] button.
     Now run the program again.  Press the [Load] button.
     Check that it really did load 3 questions.

(2) Make a new button called [Add Q].
     This should INPUT a question, answer, and picture name,
     then add this new question into the qs[] array.
     Now you should be able to add your own questions,
     press the [Save] button, and then rerun the program
     again and [Load] the questions from disk.

(3) Now make your own quiz with 5 questions,
     using 5 pictures you found in Google.

Don't spend too much time on this.  Monday we will
change the program to use a LinkedList instead of an array,
so your questions file won't work any more. 
You will need to make a new one.  So don't make lots of questions -
5 is enough for practice.

[HL] - 12 Jan 2017

Extended Essay in Computer Science?
Here is a good example Extended Essay in Computer Science:
If you are interested in the subject - Computer Science -
a simpler/better possibility is to do a World Studies extended essay,
which should involve TWO subjects, and is thus LESS DEMANDING
in each subject.  Talk to Mr. Toyne about this.


== Homework from Last Class ==

Why does a USB stick read faster than writing?
Tom's Hardware Brief Explanation
USB Stick Facing Extinction

What is the biggest Hard Disk actually used?
      10 GB ? PetaByte?  Exabyte?
World's Biggest Hard Disk
Why not make a bigger one?
How a Hard Disk Works - Parlante
Inside a Hard Drive

==  We will do the rest next class (no homework) ==

What is a BUS?

  Notes with Pictures
Topic 6 - System Resources    

Arrays of Objects - 10-11 Jan 2017

We will rewrite yesterday's quiz program
using a different data-structure -
an array of Objects.

Download this sample program.

Extra for James : http://ibcomp.fis.edu/275979/ibcomp/oop/Questions3.zip  

Data-Structures - Parallel Arrays - 9 Jan 2017

We will start writing Java programs again
now with GUI and OOP and Arrays.
We will work on this program:   Questions.zip
You should do the practice exercises
listed at the end of the Questions class (program).
Try to finish as much of this as possible today
(maybe work at home for 30 minutes)
because we will be working on a different
version of the program tomorrow.

Test on GUI+OOP - 15 Dec 2016

 import java.awt.Button;

 public class Test extends GUI

public static void main(String[] args)


new Test();


    public Test()



    Button b1 = addButton("1",50,50,50,50,this);

    Button bReset = addButton("Reset",10,10,100,40,this);


    public void actions(Object source, String command)







TicTacToe - 14 Dec 2016

Here is the finished TicTacToe program:

import java.awt.*;
import javax.swing.*;

public class TicTacToe extends GUI
    // Constructor
    public TicTacToe()

    Button b0 = addButton("",50,50,50,50,this);
    Button b1 = addButton("",100,50,50,50,this);
    Button b2 = addButton("",150,50,50,50,this);   
    Button b3 = addButton("",50,100,50,50,this);
    Button b4 = addButton("",100,100,50,50,this);
    Button b5 = addButton("",150,100,50,50,this);
    Button b6 = addButton("",50,150,50,50,this);
    Button b7 = addButton("",100,150,50,50,this);
    Button b8 = addButton("",150,150,50,50,this);

    String player = "X";  // TOGGLE

    public void actions(Object source, String command)
        doButton( (Button)source ) ;

    public void doButton(Button b)
        if(b.getLabel().length() == 0)
            {  player = "O"; }
            {  player = "X"; }  


    public void checkVictory()
        match(b0,b1,b2," top row");
        match(b3,b4,b5," middle row");
        match(b6,b7,b8," bottom row");
        match(b0,b3,b6," left col");
        match(b1,b4,b7," mid col");
        match(b2,b5,b8," right col");

    public void match(Button c1, Button c2, Button c3,String msg)
        if(c1.getLabel().length() != 0)
            if(c1.getLabel().equals(c2.getLabel()) && c2.getLabel().equals(c3.getLabel()))
            {  output("Winner is " + player + " in " + msg);

    public static void main(String[] args)
    {  new TicTacToe(); }

More Trees and Red Man - 13 Dec 2016

Download this new version of the Trees program.

Do the following practice exercises:
- add another button that opens another web-site
   it should be appropriate to the theme of the program
  Copy the code that is used for the Red Man button.
- Change the colors of all the Tree decorations
- Add a button that links to a Youtube video
   about the holiday season (or winter or snow...)
- Add a one more picture to the program window -
   but not a tree.  Maybe a reindeer or skier, etc.
- Investigate the Red Man web-site
   (e.g. have some fun!)

[HL] More System Resources - 12 Dec 2016

Chapter 5.1 in Computer Science Illuminated


-               Why does a USB stick read faster than writing?

-               What is the biggest Hard Disk actually used?
      10 GB ? PetaByte?  Exabyte?

Decorating Trees - 9 Dec 2016

You can download this program,
or continue on your old program.
The teacher will show how to write code
for decorating the trees.

*** Test - 15 Dec 2016 ***
on Thursday 15 Dec 2016.
You will have 30 minutes to fix/improve
a Java program that is similar to
the Tree decoration program we
are currently practicing.  You will be
permitted to use any notes you have,
including web-sites.

Drawing2d - 7-8 Dec 2016

We will draw a tree - use a separate class
and put it into the same program that
you worked on last class. 

You can start with a tree Button and a normal method.

Then make and use a TREE class similar to the STAR class.

Here are some notes that might help:

Here is TOO MUCH INFORMATION about Graphics2d in Java:

More Drawing Practice - 5 Dec 2016

Download and unzip this program

Open the CLICKING program and COMPILE it and RUN it.

(1) Start with the green box in the top left corner.
     Click the green box several time.
     Figure out the purpose of the variable drawingClicks.
     Change the corresponding method to allow larger values of drawingClicks.

(2) Move on to the pink box in the lower left corner.
     Click on this box several times.
     Find the corresponding method.
     Change the color of the eyes.
     Change the smile to a frown.
     Add 2 more circles for ears.

(3) There are 2 blue stars on the screen.
      Find the commands that draw these stars.
     Add 2 more stars, in appropriate locations.

(4)  Change the clown picture to a different picture.
     Then change the corresponding method/commands
     so that clicking on the clown does NOT open a web-site,
     but rather changes the clown to a different picture.
     Make this toggle back and forth between 2 pictures.

(5)  Choose any other part of the program and
     change it to do something slightly different.

OOP Practice - 2 Dec 2016

Optional Reading -  Self Driving Car Record Trip

Download this program and do the practice listed in the program documentation.

Last Day SkiTrip - 1 Dec 2016

This is our last day for the SkiTrip program.

Version 4 of SkiTrip

We will write a Sorting Algorithm to sort the names alphabetically.

*** HOMEWORK ***

Come to class tomorrow with a recommendation of
how and when the execute the [Save] method,
so that the [Save] button can be removed.

[HL] More System Resources - 30 Nov 2016

1 - Topic 6 - System Resources    

2 -  Notes with Pictures

Ski Trip 3 - 28-29 Nov 2016

Open the following project and do the tasks listed at the beginning of the program.


Here are some more useful additions:
-  a button that sorts the Students by their names, e.g. alphabetical
-  the CountVehicles button automatically enters data into the Cars and Busses boxes,
    according to whether a code occurs 4 times or less (car) or more than 4 (bus)
   Then it automatically calculates the cost for these cars and busses
-  the CountBeds method enters data into the HotelRooms and LodgeRooms boxes,
    and then executes the <Calc Cost> commands to automatically perform this function

Ski Trip 2 - 23 Nov 2016

SkiTrip2.zip Sample Program

===== Planning Notes =====

/*** Ski Trip ************************************************

Memorial High School is planning a ski trip for 188 students.

They have some choices for transportation and lodging:

- Transportation - They can use busses that each carry 20 students

  Each bus costs 1000 Euros to drive. Each car carries 4 students

  and costs 250 Euros to drive.

- Lodging - A hotel room costs 300 Euros and accomodates 4 students.

  A ski lodge room costs 800 Euros and accomodates 12 students.

They can use a mixture of cars and busses, as well as a mixture

of hotel rooms and youth hostel rooms.  The trip committee can change

the numbers of cars, busses, rooms and lodges until they find

a solution with enough seats and beds, but at minimum cost.


The code below is a “first idea” about what needs to happen.

int cars = 8;

int busses = 8;

int hotel = 10;

int lodge = 12;

int seats = cars*4 + busses*20;

int beds = hotel*4 + lodge*12;

float cost = cars*250 + busses*1000 + hotel*300 + lodge*800;

println(cars + " cars and " + busses + " busses = " + seats + " seats");

println(hotel + " rooms and " + lodge + " lodges = " + beds + " beds");

println("Total cost = " + cost);


After a bit more thought, we realize that we need to record (save)

the locations of seats in vehicles and bed locations, not to mention

the name of each student.  So we will need a CLASS so we can have an OBJECT

for each student, like this:

     class Student

         String name

         String vehicle

         String bed


We will need METHODS for all of the following tasks:

 - Save Data (Students) into a disk file

 - Load Data from disk

 - Add a new student entry

 - Change/edit/correct a student entry

 - Display all the student data

 - Search for a student

 - Count the number of SEATS required in various vehicles

 - Count the number of BEDS required


... Checking that ...

 - Data is VALID

 - Each vehicle is not overloaded

 - Rooms (beds) do not have too many students assigned

 - There are no duplicate names entered


... Printing ...

 - The list of all student names with vehicle and bed assignments

 - For each vehicle, the list of students assigned

 - For each room/lodge, the list of students assigned


Quiz - then Sorting Objects - 21 Nov 2016

Ski Trip

Shell Sort - 18 Nov 2016

It's sort ;) of like a Bubble Sort, but not really.

Here is Java Code for a Shell sort.

"JUST" copying this code into your program won't work.
It requires some "refactoring" to make it work.
We will do this is class.

Here is a video about the Shell sort.

You can watch it with the Visualization Tool.

Shell Sort Explained

The Shell Sort is FAST, but how fast is it?
We will discuss this.

You don't need to "learn" the Shell sort algorithm,
but you might wish to USE it to speed up your sorting tasks.

*** Quiz on Monday about Bubble Sort and Selection Sort ***
You should be able to WRITE the Bubble Sort and the Selection Sort
correctly in Java, using a pen and paper.  There will also be
a question about an "unknown" algorithm.

More About Sorting Algorithms - 17 Nov 2016

Here is an interesting program: http://www.cleverbot.com/  


Continue with the "Lots of Numbers" program.

We will discuss the "speed" of sorting algorithms.

When you run


it produces the following output - on an i3 Windows 8 machine.

Bubble 10000 = 0.469 sec   Iterations = 99990000
Bubble 20000 = 1.828 sec   Iterations = 399980000
Bubble 40000 = 5.825 sec   Iterations = 1599960000
Bubble 80000 = 23.767 sec   Iterations = 6399920000
Bubble 160000 = 95.973 sec   Iterations = 25599840000
Selection 10000 = 0.141 sec   Iterations = 49995000
Selection 20000 = 0.562 sec   Iterations = 199990000
Selection 40000 = 2.094 sec   Iterations = 799980000
Selection 80000 = 8.447 sec   Iterations = 3199960000
Selection 160000 = 33.812 sec   Iterations = 12799920000
Mystery 10000 = 0.313 sec   Iterations = 100000000
Mystery 20000 = 1.25 sec   Iterations = 400000000
Mystery 40000 = 4.218 sec   Iterations = 1600000000
Mystery 80000 = 17.89 sec   Iterations = 6400000000
Mystery 160000 = 71.796 sec   Iterations = 25600000000
Smart Bubble 10000 = 0.312 sec   Iterations = 49995000
Smart Bubble 20000 = 1.297 sec   Iterations = 199990000
Smart Bubble 40000 = 3.75 sec   Iterations = 799980000
Smart Bubble 80000 = 15.201 sec   Iterations = 3199960000
Smart Bubble 160000 = 61.446 sec   Iterations = 12799920000

[HL] System Resources - 16 Nov 2016

0 - Discuss the solutions to the Book Index Algorithm
     You might want to read a bit of this article

1 - Topic 6 - System Resources    

2 -  Notes with Pictures

Intro to Operating Systems Video

More Sorting Algorithms - 14-15 Nov 2016

Here is a better version of the "Lots of Numbers" program.

We will discuss the "speed" of sorting algorithms.

Here is an interesting program: http://www.cleverbot.com/  

Sorting Algorithms Practice - 9-11 Nov 2016

The teacher is away this week.  You should do the following assignments
(in whichever order you prefer).

-  Lots of numbers : http://ibcomp.fis.edu/275979/ibcomp/ibBook/javaBasics/BubbleSort/index.html 

-  In your textbook, read p.564-571 (write down questions to discuss on Monday)

-  Sorting names : http://ibcomp.fis.edu/275979/ibcomp/ibBook/javaBasics/CDlistSorted/index.html

-  Try out this game (don't get hooked) : http://2048game.com/

Sorting Algorithms - 8 Nov 2016

Bubble Sort Video

Visual Sorting Algorithms

Sorting Explained with Java Code

Java Algorithms (including Sorting)

Sorting Program

New Books - 7 Nov 2016

- QUIZ -
Spend 30 minutes on your quiz.  Pens only, no computers.
Turn it in when finished.

- Read about Sorting -
In your textbook, read about
Selection Sort and Bubble Sort
on pages 218-222.

- Investigate your New Textbook -
HL students may work on their HL homework,
writing an ALGORITHM for producing an index.

[HL] System Resources - 3 Nov 2016

0 - Distribute Textbooks

1 - Topic 6 - System Resources    

2 -  Notes with Pictures

Intro to Operating Systems Video

More Number Arrays - 1-2 Nov 2016

Here are solutions to yesterday's NumList problems.

Some numlist puzzles problems.

Sorting Explained with Java Code

Visual Sorting Algorithms

Java Algorithms (including Sorting)

Arrays of Numbers - 31 Oct 2016

Here is a finished version of the ArraysOfWords program,
including the improved doAdd() method.

We will discuss this program about arrays containing numbers.

*** Quiz on Arrays ***

On Mon 7 Nov, we will have a 25 min written quiz about arrays.

More Arrays of Words - 27 Oct 2016

Here is the ArraysOfWords program,
including a Delete function.


Write a better doAdd method, like this:
        // Plan in Pseudocode
            check whether full
               if full then return (quit)
            print a list of free rooms
            input a room num
            check if it's vacant
               if not, try again, until you find vacancy
            input a name
            loop through all the rooms to find the name
               if found, ask whether you want another room
                  if yes then
                      reserve num for name, FINISHED (return)
            end loop
            reserve num for name
 HOMEWORK = write Java code for this

Arrays of Words - 26 Oct 2016

Insert Alphabetically - 25 Oct 2016

We will finish #10 in Version 2 of the SearchLists program.

Then we will work on LOADING all the words in this list of words
into an array.  Then we will do some SEARCHING in the array.

[HL] System Resources - 24 Oct 2016

Intro to Operating Systems Video

1 - Topic 6 - System Resources     
2 -  Notes with Pictures

What is an Operating System (OS)?  What do you know about it?

Input, Processing, Output

Browser can access only one type of file

OS can access a variety of files available to the computer

Windows, IOS, Linux

Manages - computer hardware

Manages memory

Simple function - getting the time

Complicated function - opening a program

OS is not the first thing that is loaded – BIOS comes first

OS gets updated – once a year
as opposed to hardware

Jeopardy - 21 Oct 2016

We will continue the Searching Lists program on Monday.

Today, you can download this program:  Jeopardy

Add more questions, going up to at least 300 in each category.
It's programming practice - try to become fast and reliable.

More Searching in Lists - 20 Oct 2016

Download Version 2 of the SearchLists program.

Start with #7 today.  Then do 8, 9 and 10 in the next 2 days.

Searching in Lists - 17 Oct 2016

Download this program and do the practice exercises.

Lists of Words - 14 Oct 2016

(1) 5 minute quiz

(2) Discuss the September Test

(3)  We will be learning about:
       - lists
       - arrays
       - sequential search
       - binary search

We will be using this list of words
and this program.

We might also use this random list of words.

Here is a list of names by popularity:  Given Names.txt

Lists of Words - 13 Oct 2016

(1) Return end of September Test

(2)  We will be learning about:
       - lists
       - arrays
       - sequential search
       - binary search

We will be using this list of words
and this program.

We might also use this random list of words.

Here is a list of names by popularity:  Given Names.txt

Here is a text file for future use:  Airports.txt

*** HOMEWORK ***

STUDY the Airports.txt file,
especially looking for SYNTAX RULES.
And find out what ICAO and IATA mean.

5 minute QUIZ Tomorrow.

[HL] More about Signals - 12 Oct 2016

1 - We will discuss the answers to #12 homework about the fire station.
2 - Topic 6 - System Resources    
3 -  Notes with Pictures

Mid-term Test Review (Test tomorrow) - 29 Sep 2016

Scan this ENTIRE BLOG to remind yourself what we studied.
Do some experiments with some of the programs that we practiced.

The test will include the following items (and maybe other things):

     Java: calculations, variables, Strings,  if.. commands , Dates and times , GUI programming
     Theory : , Characters and ASCII and Unicode

     HL = embedded control systems

     HL students will have a slightly longer test, including questions about embedded control systems.

Auto-rolling Dice - 28 Sep 2016

Look at this program

We will transfer the ALGORITHMS into our GUI DICE program.

More GUI Programming - 26 Sep 2016

***  Test Announcement - Mid Term Test 30 Sep  ***
***  covers everything we have studied this year ***

Questions/problems about Friday's practice?

We will work on this program:  EasyDice(GUI)
You should do the practice exercises
listed at the end of the EasyDice class (program).
Try to finish as much of this as possible today
(maybe work at home for 30 minutes)
because we will be working on a different
version of the program tomorrow.

GUI Demo Program - 23 Sep 2016

Download this program and open it in BlueJ.
BluejGUI example program

Do as many of the following exercises as you can during class.
No need to work on this at home - we will continue on Monday.

GUI - 22 Sep 2016

Getting Started

To get started, you should download 2 files:

-  BlueJ IDE at http://bluej.org
   Get the version WITH Java 8 SDK

 BluejGUI example program

The teacher will demonstrate how to use BlueJ, 
and explain how the BluejGUI example program works.

Here are some sample projects.

Here is a video with a basic introduction for writing your first program

Here is a printed introduction, just like the video

Here is a brief user's manual, in case you want to learn more about BlueJ

Here is a textbook about BlueJ and OOP
     Objects First with Java: A Practical Introduction Using BlueJ

[HL] Embedded Systems - 21 Sep 2016

IBCS Course Guide     M Brookes Notes on Item 7

The Internet of Things (IoT) video

IoT is Bigger than we Think

How Big is IoT?

Last Year - 20 Sep 2016

Use Google, books, web-sites, other peoples' brains, whatever.

Find out how to INPUT today's date (or maybe get it automatically)
and then produce the date that is 1 year ago,
without using a calculation like:   1000L*60*60*24*365 (or 366).

Try to find a BUILT-IN Java method (maybe in java.util.Date)
that can subtract exactly one year from a Date.

Real DATES - 19 Sep 2016

Wu Java Book section 2.4.3 about Dates

Notes about Date and Time in Java.

Background Info about Dates and Times

import java.util.*;


public class CountDays
    public static void main(String[] args)
        new CountDays();  

    public CountDays()
        Date today = new Date("30 Nov 2016");
        Date yearEnd = new Date("31 Dec 2016");
        long dayMillis = 1000*60*60*24;
        long days = ((yearEnd.getTime()-today.getTime())/dayMillis);
        output(days + " days\n" +
               "between " + today.toString().substring(0,10) + "\n" +
               "and " + yearEnd.toString());

    public String input(String prompt)
    { return javax.swing.JOptionPane.showInputDialog(null,prompt); }
    public void output(String message)
    {  javax.swing.JOptionPane.showMessageDialog(null,message);  }


Brief Overview of Dates and Times

We will also discuss all the details in this program:

import java.util.*;      // Date
import java.text.*;      // DateFormat

@Deprecated              // Ignore Date depecration warnings

public class Holidays
    public static void main(String[] args)
    {  new Holidays(); }

    public Holidays()
        Date now = new Date();
        output(now.toString());  // what will this show?

        DateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
        String today = formatter.format(now);
        output(today);           // what will this show?

        String yesterday = "" ;  // make this calculate yesterday's date
        output("Yesterday = "+yesterday); // show German format


    public void howOldAreYou()
        String born = input("Type your birthdate as: dd MMM yyyy");
        long bornMillis = new Date(born).getTime();

        Date today = new Date()  ;    // make this equal today's date and time

        long todayMillis=today.getTime() ;  // make this equal today's milliseconds

        long aliveMillis = todayMillis - bornMillis;

        long yearMillis = 1000L*60L*60L*24L*365L ;   // calculate milliseconds in one year
                                                     // 3.154e+10
        long age = (long)(aliveMillis / yearMillis);

        output("Your age is " + age);

    public String input(String prompt)
    { return javax.swing.JOptionPane.showInputDialog(null,prompt); }

    public void output(String message)
    { javax.swing.JOptionPane.showMessageDialog(null,message); }  

Dates in Strings - 15 Sep 2016

(1) Brief quiz - 10 min on paper, no computers

(2) Library books - dates and overdue charges

Times in Strings - 14 Sep 2016

== Time Check ==
The following code asks the use
r to type in the time for an appointment.

They MUST type it in the format  hh:mm , like 08:45
This code checks whether it is in the correct format.
It is incomplete - fix it.

   String time =  input("Type the time as hh:mm");

char third = time.charAt(____);

if( third == _______ )
output("BAD format");

Add some more commands to check the following:
  1. The input must contain exactly 5 characters
  2. The first character must be 0, 1 or 2
  3. The 5th character must be a digit 0,1,2,... 8 or 9
  4. The 4th character must be 0,1,2,3,4 or 5
  5. The second character must be 0..9 if the first is 0 or 1,
    but must be 0,1,2, or 3 if the first character is 2.

Strings - 12-13 Sep 2016

String Notes and Practice

String Methods and Functions

George Washington Initials

        String first = name.substring(0,1);
        int s = name.indexOf(" ");
        String second = name.substring(s+1,s+2);

The whole Initials program

public class Test
    public static void main(String[] args)
        new Test("George Washington");
        new Test("Madonna");
        new Test("");
        new Test("George X Y Z Peacock");

    public Test(String name)  // parameter
        System.out.println("Name = " + name);
            System.out.println("Empty string, no initials");
            String first = name.substring(0,1);

            int s = name.lastIndexOf(" ");    // produces -1 if no space
            if(s == -1)
                String second = name.substring(s+1,s+2);
        //  + is POLYMORPHIC = has more than one meaning/function
        // char is a PRIMITIVE type, not a class/object
        //  does not contain Methods


[HL] Embedded Processors continued - 9 Sep 2016

1.  Khush will present his findings about Automatic Doors.

2.  All will tell STORIES about their devices.

3.  Past Paper Question - May 2015 Paper 1 #12

** HOMEWORK ************************************
Write answers to the fire-station question (above).
This should take less than 1 hour (during an exam
you would do this in 20 minutes. 
Hint 1 : 
    a 4 point question requires 4 ideas.
    So question (a) probably requires 4 sentences or more -
    but not a lot more than 4 sentences.  So your written answers
    to these questions should certainly fit on one page (probably less).
    There are 15 points, so probably 15-20 sentences altogether.

Hint 2 :
    These questions do not have "right" or "wrong" answers.
    They do have "better" and "worse" answers.
    Try to write "good" answers, but don't worry about them being "right".

Bring your written answers to the next HL class.


Character Codes and Encryption - 8 Sep 2016

1. Questions about the passwords article?


Read Section 2.5 in McFadyen (p.46-59)

Here is a simple sample encryption program:

public class Encryptor

    public static void main(String[] args)
        new Encryptor();

    String plainText = "secret message for today";  // input("Type the plain text");

    public Encryptor()
        String crypText = encrypt(plainText);
        output("Original message = \n" + plainText +
               "\n\nEncrypted = \n" + crypText);

    String encrypt(String plain)
        // split up the letters .substring
        // change ASCII codes by adding 1 or 2
        String result = "";
        for(int c = 0; c < plain.length(); c = c + 1)
            char ch = plain.charAt(c);
            char nch = (char)(ch + 1);

            result = result + nch;
        return result;  

    public String input(String prompt)
    { return javax.swing.JOptionPane.showInputDialog(null,prompt); }

    public void output(String message)
    { javax.swing.JOptionPane.showMessageDialog(null,message); }


Russian Passwords - 2 Sep 2016

         Is there an easy way to find out what this means (in English)?

ASCII and Unicode - 1-2 Sep 2016

FIRST - 10 min Java quiz

Second - Password and ID

Homework = in the Password program, make one of the passwords be in Russian (Cyrillic) characters

[HL] Embedded Devices - 30 Aug 2016

Shruti    Washing Machine

Jasmin    GPS

Alex       Elevator

Catherine   Device Drivers

Michael       Heating Systems

Gwen        Traffic Lights

Khush      Automatic doors


In each case, consider the following questions:

  1. What input devices (sensors) must exist in the system?
  2. What output devices (actuators/transducers or motors) must exist?
  3. What processing must occur to make the system function correctly (input-processing-output)?
  4. What rules must be implemented as decisions in the embedded controller?
You might want to think about processing first, and then think about inputs and outputs.

IBCS Course Guide     M Brookes Notes on Item 7

More If Commands - 29 Aug 2016

Converting Units

We will have a quiz on Thursday.
You will need to fix a Java program, using your computer and notes.

Cafeteria Calculations - 26 Aug 2016

/*** Cafeteria ************************************
  This is a very simple example of the calculations
  needed in a cafeteria cash register.  It demonstrates
public class Cafeteria
    public Cafeteria()
        double sandwich = inputDouble("Sandwich price");
        double drink = inputDouble("Drink price");
        double total = sandwich + drink;
        output("Total = " + total);
        double paid = inputDouble("How much do you want to pay (e.g 10.00)?");
        double change = paid - total;
        output("Your change is " + change);

    public static void main(String[] args)
    {  new Cafeteria(); }

    static String input(String prompt)
    { return javax.swing.JOptionPane.showInputDialog(null,prompt); }
    static double inputDouble(String prompt)
    {  double result=0;
        catch (Exception e){result = 0;}
        return result;
    static void output(String message)
    { javax.swing.JOptionPane.showMessageDialog(null,message); }

/*** Sample Output ********************************
   Sandwich Price --> 3.50
   Drink Price --> 1.75
   Total = 5.25
   Paid --> 10.00
   Your change is 4.75

Make this program better by doing the following:

-  add a Dessert Price

Solving a Calculation Problem - 25 Aug 2016

Car Trip

Basic Java Lessons

Java Calculation Problems - 23 Aug 2016

Calculations + - * /

Homework : read section 2.3.2 in McFadyen Java Book

Solving Equations in Java - 22 Aug 2016

   Solve Math Equation

 == Homework ==

    Read McFadyen 2.1+2.2 (Java and BlueJ)

BlueJ Java + Discussing System Scenarios - 19 Aug 2016

We will also check that everyone installed BlueJ successfully
by running this very simple Java class:

 public class Test

=== Homework ===

Read McFadyen 1.4-1.5 (
Java and BlueJ)
Type in the Hello World program and make it run correctly.


If time permits, we will also discuss the 2 scenarios at
the end of the Computer Systems Notes .

[HL] Embedded Control Systems -  18 Aug 2016

=== Homework (due 30 Aug) ===

Investigate YOUR chosen device.  Answer question 1-4 completely and thoroughly.


Shruti    Washing Machine

Jasmin    GPS

Alex       Elevator

Catherine   Device Drivers

Michael       Heating Systems

Gwen        Traffic Lights

Khush      Automatic doors


In each case, consider the following questions:

  1. What input devices (sensors) must exist in the system?
  2. What output devices (actuators/transducers or motors) must exist?
  3. What processing must occur to make the system function correctly (input-processing-output)?
  4. What rules must be implemented as decisions in the embedded controller?
You might want to think about processing first, and then think about inputs and outputs.

For the most part, there is little storage in embedded controllers, or at least nothing interesting.


IBCS Course Guide

7.1.1   Discuss a range of control systems.

A variety of control systems should be examined such as:

- automatic doors

- heating systems

- taxi meters

- elevators

- washing machines

- process control

- device drivers

- domestic robots

- GPS systems

- traffic lights

. . . and other common devices.

Technical knowledge of specific systems is not expected

but students should be able to analyse a specified system.

7.1.2   Outline uses of microprocessors

               and sensor input in control systems.


We will study some sample control systems.

In each case, consider the following questions:

  1. What input devices (sensors) must exist in the system?
  2. What output devices (actuators/transducers or motors) must exist?
  3. What processing must occur to make the system function correctly (input-processing-output)?
  4. What rules must be implemented as decisions in the embedded controller?
You might want to think about processing first, and then think about inputs and outputs.

For the most part, there is little storage in embedded controllers, or at least nothing interesting.

First Day - 17 Aug 2016

Today's Assignment

- What is COMPUTER SCIENCE?   http://www.macmillandictionary.com/us/dictionary/american/computer-science

- How do we define the term COMPUTER?  http://searchwindowsserver.techtarget.com/definition/computer 

- We will discuss these notes Computer Systems Notes about computer SYSTEMS.


-  install BlueJ from http://bluej.org
Download the version WITH Java JDK installer

-  Read these notes Computer Systems Notes
and be prepared to discuss them next class.



Brief Overview of Dates and Times

LocalDateTime Quickstart   More Notes

Too Much Info about Java 8 (Chap 12) (don't read this)