IB Comp Sci HL+SL y1 exams 2020

LINKS:   Lewis+Loftus Java Book   Java Tutor   Java Reference  Comp Sci Illumin Book 
              Basic Java Lessons   Java OOP   JETS    Internal Assessment Java Notes  
                Vocabulary   IB CS Course Guide     Pseudocode     Notes and Review 2019
            Swing Guide
 
Due Dates : Visual Prototype and Client Discussion Notes - 
       due Monday 20 May at 18:00


Exam Schedule - 27 May 2019

Please note that the IB Computer Science End of Year Exam is scheduled for:

      Multi-Purpose-Room  S.022 (below the gym)
       6 June - starting at  9:00 (arrive 8:45)


Some Useful Practice - 24 May 2019


Write the following programs in NetBeans

Sorting : write a program that inputs numbers, stores them in an array,
       until the user types -999.  Then it stops (does not store -999),
       sorts the array and prints the sorted result.

Weekdays : Use loops to print 
         Mon
         Tue
         Wed
         Thu
         Fri
         Sat
         Sun
  and then repeat that 52 times, for all the weeks in a year.

Strings :  Use String methods to input a word
       and then decide whether the word ends with "s" or not 

LInkedList : input words and store them in a LinkedList.
      After each input, examine the ENTIRE LinkedList
      to see whether it is a duplicate - the same word twice.
      If the word is already in the LinkedList, then do NOT
      add it (no duplicates).  When the user types "quit",
      the program should print out all the words in the LinkedList
      and then stop running.


[HL] Queues - 23 May 2019

Sample program:
We will work on the Waiting program, which uses the Queue class.

Queues in the Counselling Office

Imagine students are sitting in the counselling office on a row of chairs, waiting to talk to the counselor..  Each new student sits behind the last student.  There are 5 chairs.

>> Empty (beginning of the day)
 
:______:    :_____:    :_____:    :_____:    :_____:
   1           2          3          4          5
 
>> First student arrives (Al)
 
:__Al__:    :_____:    :_____:    :_____:    :_____:
   1           2          3          4          5
 
>> Second student arrives (Betty)
 
:__Al__:   :_Betty_:   :_____:    :_____:    :_____:
   1           2          3          4          5
 
|>> Al goes into the counselor's office
 
:______:   :_Betty_:   :_____:    :_____:    :_____:

1 2 3 4 5
 
>> Carla arrives   :______: :_Betty_: :_Carla_: :_____: :_____:

1 2 3 4 5
 
>> Doug arrives   :______: :_Betty_: :_Carla_: :_Doug_: :_____:

1 2 3 4 5
 
>> Betty goes into counselor's office   :______: :_______: :_Carla_: :_Doug_: :_____:

1 2 3 4 5
 

Question 1:  Who is "next in line" to see the counselor now?

Question 2: What happens if 2 more students come into the office?
      Where should they sit?

If the students are not very organized, or if the chairs are scattered around, or if there are lots more chairs,
it might be useful to have a computer where the students "sign in".  Then they can sit wherever they like.  
Indeed, they could go back outside for a few minutes without "losing their place."
Whenever a student leaves, the counselor presses the "next" button on the computer, 
and it tells who is next in line. 

The WAITING program uses a queue to keep track of students waiting in the counselor's office.
A queue is a FIFO data structure = First In, First Out.

Notice that the subroutines are generic – that is, the operations Initialize, EnQueue, and Dequeue would be needed in any queue in any application.  The same ideas could be used to manage a queue of patients in a doctor's office, a queue of print jobs in a print server (spooling), and in many other practical situations.

Question 3:  What is the meaning of the variables  Head and Tail?  
       
How many "chairs" does the program have?

Notice that the DeQueue command is a Function. Why? Because it outputs a name, so it returns a result. On the other hand, the EnQueue command accepts an Input Parameter – the name which is entering (input) the queue.

Question 4: It is quite possible that the Queue will overflow.  This could be solved by allocating more memory. However, as the day progresses, the data "crawls" through the queue, so even with 100 positions it is conceivable that the Tail pointer could overflow. Suggest a solution to this problem.  Which method must be changed?


More Hints about Final Exam - 22 May 2019

Don't forget topic 1.2 about software system development
SL students must know how to program 2D arrays
No JTables in the Final Exam
No questions about Algorithm Efficiency in the exam
Don't forget the Fetch-Decode-Execute-Store cycle
Don't forget what we studied about Operating Systems
[HL] we will review ADTs tomorrow


More Exam Review - 21 May 2019

We will discuss the practice exam from yesterday.

Reviewing for Final Exam - 20 May 2019

These are not identical to this year's exam, as we studied
some different topics.  But it is similar.
But you still need to REVIEW the ENTIRE YEAR that we did,
especially be reviewing this ENTER BLOG.


Finish your Visual Prototype - 16 May 2019

You may use today's class to finish your Visual Prototype,
or maybe ask some questions.  If you're already finished,
then do some useful work for another class.
Or you may start reviewing for your final exam by
reading through this entire web-site, starting in August.

On Monday, you will receive a review assignment to help
you prepare for the final exam.


Topic 1.2 vs IA Project - 14-15 May 2019

We will discuss how the general concepts in Topic 1.2 are connected
to your IA project.   topic 1.2

Why a Prototype is important - here are prototypes for a garden swing


Planning for the Client Interview
- write down some questions (a script) that you plan to ask
- take your script with you to the interview
- encourage the user to TELL STORIES about their problem
- be sure to SHOW YOUR VISUAL PROTOTYPE to the user
- TAKE NOTES during the interview
The NOTES from your interview and the VISUAL PROTOTYPE
are due to be submitted on Monday 20 May.

Here is a video by a professional designer with some useful ideas
about how to conduct a client interview:
https://www.youtube.com/watch?v=8tiuWYs5Z-A
These are general concepts - it's not a "formula".


[HL] Continue Working on Visual Prototype - 13 May 2019

*** Class meets in the Atrium today. ***

Visual Prototype - 6 May 2019

Before your first discussion with your CLIENT, you should produce a 
Visual Prototype.  This clearly illustrates your ideas, so you can SHOW
the client what you intend to create.  

It is recommended that you use PowerPoint or Google Slides to produce
your visual prototype.  It should change from slide to slide when you click,
showing the results of normal activities by the user, similar to the 
Tic Tac Toe prototype.  There is no "rule" about how many slides you need
or what must be included, but you should try to show:
- the normal interface
- typical sample data
- at least a couple examples of AUTOMATION

(in case you wish to create the Visual Prototype in some other way,
for example using pen and paper, then you will need to figure out a way
that you can submit this in Haiku.  One possibility is to create a video
showing what the prototype looks like when you present it to the client)

You may find it difficult to "think ahead" and predict what your program will do.  
Don't try to be "perfect" or "totally complete".  The purposes are:
- spend time thinking carefully and clearly about what you intend to do
- produce a prototype that will ease the discussion with your client

This is part of the Software Development Process.  You should keep a 
copy of your Visual Prototype and submit it with your finished IA project
next year.  You will also submit a copy to the teacher next week along
with written notes from your discussion with your client. Those notes will
also be submitted with your project next year, so don't throw them away.

Spend this week creating your Visual Prototype and thinking about who 
your CLIENT (potential user) will be.  You will need to discuss your 
Visual Prototype with the CLIENT in time to 
turn in the Visual Prototype and Client Discussion Notes on Monday 20 May.


Choose a Topic (think about a client) - 3 May 2019

Topic Ideas

-- IBO Examples -- 

    More samples, especially Java programs, are available at:
     Teacher Support Material Overview  

Here is a complete overview of the IB Comp Sci IA Project:


Starting Internal Assessment - 2 May 2019

=== HOMEWORK =====
Read about Choosing a Topic - you need to have a topic by
the beginning of class on Monday.

------------------------------------------------------------------------------

== Prototypes ==
We will start with a Visual Prototype. 

What is a Prototype? (watch this)

Why are Prototypes Important? (read this)

Start Simple: (do this)

== IA Project Overview ==
Here is a complete overview of the IB Comp Sci IA Project:
These were the notes for the current grade 12 students.
These will be slightly different for to 2020 students -
especially the due dates.  But the due dates will be similar,
and the finished project will still be due at the end of February 2020.



[HL] Robots - 17 Apr 2019

We may have a visit from a small friend.
https://www.youtube.com/watch?v=in5HibrKDyA

In any case, we will play with this simulator:



Usability - 12-15 Apr 2019

Start with these videos:

We can improve USABILITY by making clear, informative displays
sometimes using special GUI COMPONENTS - tabs, spinners, images, etc.
Here is a program that demonstrates some of these components:

== HOMEWORK ==
Download the program, add another tab, put something in it and make it work.
Then do another tab, with a PICTURE.
~~~~~~ Lecture End 12 Apr ~~~~~~~~~~~~~~~~~~~~~~

Don't forget SKEUOMORPHISM

Sample Programming Project
We will write a program using a Tabbed Interface.  
This makes it easy to combine lots of different objects.

The program must present several educational or interesting questions.  
The user must select an answer, and the program tells them whether they are correct.
Include a variety of types of questions/answers/controls, e.g.:
- true/false - using Buttons
- multiple choice - using Radio Buttons
- selecting from am awt.List box
- fill-in-the-blank, using a TextField
- multiple correct answers, using Buttons
   that change color and/or become inactive
- anything else that is different/challenging/entertaining
   more variety is better
- show an image using a jLabel and Icon
- show a web-page using a JEditorPane
Put each question in its own TAB.

The program should include a TIMER that measures
the total amount of time between starting and ending.

Software Development Ideas :

Usability Testing

Usability is another term for User Experience.

=== Software Development Overview ===


Looking Ahead at the IA Project - 10 Apr 2019
We will look at some of the information in these notes - just some parts of it.


Software Development - 9 Apr 2019

We will discuss Software Development as it relates to these notes:  topic 1.2


Finish Notes Program + User Docs - 8 Apr 2019

Finish up your Notes Program + User Documentation.
Turn this in to Haiku before 18:00.
You must turn in 2 files:
- .zip archive containing compressed NetBeans project
- document (.docx or pdf - no Pages documents) containing User Instructions

If you finish earlly, you can begin reading these notes:
topic 1.2 notes
We will be discussing these notes in class tomorrow.


[HL] ADT's, Stacks, Queues - 5 Apr 2019

You can read about STACKS and QUEUES in Data Structures .

We can create an ADT, for example a Stack, by writing a Class containing an array filled with data.

Here is a sample program containing a Stack:
https://drive.google.com/file/d/1Vj91IRKoOGAnZroNRblIW2p7XBZLUVP-/view?usp=sharing

== Practice ==

- Download the sample program and run it
- Try clicking about 10 buttons quickly, and see whether
   you can correctly state the moves to return to the start
- Convince yourself that the [Return] button produces correct results
- Add an UP button and a DOWN button.  These would be for
  climbing/descending stairs.  Change the [Return] button so it
  produces correct results when the UP and DOWN buttons are used
- Add a button for JUMP - that means jumping 3 steps ahead.
  Again, add a corresponding move to the [Return] button.

Create a new program that inputs a sentence (in a JTextField).
Then it takes it apart one character at a time and PUSHES
each character into the Stack.  Then use a POP loop to retrieve
all the characters in reverse order, and display these as a String
in a results field.


Revision - 3-4 Apr 2019

Alpha Testing vs Beta Testing vs Acceptance Testing:


Now that you have received feedback from your Beta Tester, you should take time to REVISE your program - fix any bugs, improve any difficult interface issues.  You should not be adding new features, but some may be necessary to fix some of the problems.

More importantly, you need to write USER INSTRUCTIONS. Think about questions that your Beta Tester had.  Then write instructions for the ACCEPTANCE TEST - this is when a software product is presented to the INTENDED USER and they test it to decide whether it is acceptable or not.  As a student, your ACCEPTANCE TESTER is the teacher.  

This video may help you to focus your efforts:

We will discuss what a sensible deadline is.


Finishing Up - 2 Apr 2019

Most people's only experience with software is USING it.  They don't know what is inside or HOW it works.  If you ask them "explain how this software works", they will tell you about how they USE it.  It's no good explaining to them about Java commands and GUI controls.  They want to know which buttons to click and which order.

To provide a good User Experience (UX), the programmers need to INVESTIGATE the user's needs - preferably before writing the program - and then DOCUMENT the program usage after the program is finished.  We skipped the investigation on the NOTES program, but we will write some user documentation. 

We will start with a BETA TEST.  During software production, programmers must test their own programs - that is called ALPHA testing.  Once the program is almost finished, and usable but not fully debugged, then it is released to actual USERS who try it out - that is the BETA test.  The BETA testers promise that they will report back to the programmers about the good and bad aspects - especially any errors, but also USABILITY issues.  

Now we will EXCHANGE programs and do BETA tests on each others' programs.  There are two important things to do:

(1) the PROGRAMMER must EXPLAIN his intentions to the USER.  He may want to SHOW the user how the program works, running it at the same time that he is explaining.  He should try to address ALL the features.

(2) the USER must run the program and write NOTES about the good and bad things, especially errors and usability problems.  it is very important that the USER is doing this WITHOUT talking to the programmer.  That may seem unnecessarily difficult, but real software users NEVER have a programmer sitting next to them.

(3) IF the user gets really stuck and cannot figure out how to do something, then he needs to WRITE a question - maybe send an email.
Or it could be written on paper and handed to the author, but it must be WRITTEN.  And he must receive a WRITTEN answer.

Today, choose one partner.  Exchange programs and exchange explanations.  Then spend the rest of the class TESTING the other person's program, and WRITING notes about it.  You may decide together how you wish to write and exchange the notes.


List Management Code - 22-29 Mar 2019

Here is Java code for a simple program that maintains a List of words,
saves the list into a disk file, and then loads it back again later.
When the user clicks on a word in the list, something can happen.
You can copy this code and use it in your Notes program if you wish.

    public boolean loadList(List list,String filename)
    {          // This loads a list of words from a text file and inserts them in an AWT.List box
        try
        { list.removeAll();
            BufferedReader infile = new BufferedReader(new FileReader(filename));
            while(infile.ready())
            { list.add(infile.readLine());                      // inputs one line of text from the file & adds it to the List box
            }
            infile.close();
            return true;
        }
        catch(IOException e)
        { output(e.toString());
            return false;
        }
    }

    public boolean saveList(String filename,List list)
    {            // This copies all the Strings from and AWT.List box and saves theme in a text file
        try
        { PrintWriter outfo = new PrintWriter(new FileWriter(filename));
            for (int c=0;c<list.getItemCount();c++)
            { outfo.println(list.getItem(c));              // takes one entry from the List box and prints it into the file
            }
            outfo.close();
            return true;
        }
        catch(IOException e)
        { output(e.toString());
            return false;
        }
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        String word = input("Type a new word:");
        list1.add(word);                                                // adds a new word to the List box
    }                                        

    private void list1ActionPerformed(java.awt.event.ActionEvent evt) {                                      
        String chosen = list1.getSelectedItem();
        output("I should do something with " + chosen);        // responds to a double-click in the List box
    }                                     

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       loadList(list1,"words.txt");                                        // the Load button
    }                                        

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       saveList("words.txt",list1);                                      // the Save button
    }                                        



Notes Program - 21-29 Mar 2019

Download this project:

The goals of this project are:
- create a program for quickly writing short notes, for example daily 
homework assignments for math, or keep notes for the Extended Essay, 
or writing and saving brief messages before sending them as email
or instant messages.
- primary focus on USER EXPERIENCE.   The program does not need
to perform any impressive processing features.  Rather it should be
VERY FAST and VERY EASY to use. 
- focus on DESIGN before programming, and design for SPECIFIC purposes.

We will work on this during class until 29 Mar.  
The program is due on 29 Mar at 18:00 -
compressed and uploaded into Haiku.

Here are some good ideas - you can implement any of these,
but also add some of your own ideas.

- Saving -
The program needs to save the text into a text-file on the hard disk.
Now it might be good to do this automatically at the end of the program,
but it might also be a good idea to do this frequently AUTOMATICALLY,
like after every 20 keystrokes or so.  

- Loading -
It is convenient to do this automatically when the program starts.

- Multiple Files -
For a while (say a couple weeks) it might be adequate to type everything
into one single text file, like writing notes in a single calendar book.
As the file gets bigger and bigger, it might be desirable to make several
different files for different purposes, like Math, appointments, EE notes, etc. 
 If this is done, the user must be able to change from one file to
another, but this should be quick and easy.  For example, if there is 
a LIST box on the left side with names of all the files, when the user
clicks on a file-name then it instantly loads - but AUTOMATICALLY saves
the current file before changing to the next file.

- Special Characters and Words -
If the user types special characters, like PI, it is probably painful and 
time consuming.  Hence a special button that inserts the PI symbol at 
a single click is helpful.  This applies to special German and French 
letters too.  It might also be helpful to have buttons for commonly used
long words, like Dictionary or Encapsulation, etc.  

- Expandability - 
Every user will have different needs and wishes.  Instead of making 
specific buttons for specific letters, it is better to allow the user to create
a list of special letters, then present this list in a menu or a List box,
and insert the letter (or phrase) when the name is clicked.  The same 
applies to a list of file-names.

- External Programs - 
You can execute external programs, like the system calculator, or a browser, 
or a Word-Processor.  The needed methods are included in
the sample Notes program.  Like other items, a list of external tools
should be customizable.  

- Customizations - 
All CUSTOMIZATIONS (settings) must be SAVED and then LOADED 
when the program starts.  This sort of thing is called a SETTINGS FILE.
That works the same as data files, but after loading the SETTINGS FILE 
the program must PARSE the file and construct the appropriate 
clickable list.

- Dates -
Dates are a common need, especially looking into the future and
 counting days.  A feature that helps with dates (or perhaps 
an external tool) is probably a useful feature.

- Calculations -
Even though an external calculator is available, it is still sometimes 
quick and useful to have some simple calculations built in - for example,
a money converter, etc.  

Those are all pretty standard ideas.  You should be designing this
for a SPECIFIC PERSON/PEOPLE or a SPECIFIC PURPOSE.
That doesn't mean it has only one function, but rather a collection
of features that fit together to make a good tool for a specific kind of
person, like a STUDENT or a TEACHER or a BUSINESSMAN.

When your program is finished (or at least when you stop writing it),
you will need to also write an OVERVIEW of the features provided.
This is not a detailed user's manual, but rather an INTRODUCTION 
to the program. You can write this after 29 March - in the following week.


The ADDING Project - 19 Mar 2019

We will discuss the problem of writing a program for adding numbers.
We will look at this prototype:


UX - 18 Mar 2019


"User Interface" is the simple, old-fashion term.  For example, does the user prefer the Mac UI or the Windows UI?
"User Experience" (UX) is the more modern, complex concept.  
There is more to using a computer than just the UI.
For example:
- is the system fast or slow?
- is it reliable?
- does it require training, knowledge or skills?
- is it changeable/configurable?
- does it present lots of information, or just the information that I need?
- etc

UX = User Experience

The User Experience should be
- easy
- fun
- successful
- complete
- powerful
- cool? exciting?  Maybe...
and lots of other things.

Don't let your design be overwhelming and driven by technical details.
At the very least, WRAP it in a nice UI (User Interface).

Here is a video about UX by a famous DESIGNER (he's also an engineer):
https://www.youtube.com/watch?v=RlQEoJaLQRA&list=PLR84EITvtzM3iCs3PWHBli8SuXtqvuhwE

Reasons to Prototype:
https://designshack.net/articles/graphics/how-why-prototypes-are-mandatory-for-good-design/

== Failures in UX and Poor Design/Prototypes ==


Schedule Programming Test - 15 Mar 2019

Bring printed notes with you.

When your test is finished, you may turn it in and start reading the articles below -
finish reading at home.

=== HOMEWORK === 
Here is some reading about HCI = Human Computer Interfaces

Ethiopian Airline Crash

6 HCI Disasters

[HL] Continue with Trees - 14 Mar 2019

Briefly discuss useful tools for investigating:
   Ax + By = C
solutions in non-negative integers for x and y.
For example, in honor of PI DAY:
  314x + 159y = 49454
Try getting help from Wolfram Alpha at:


Traversal Notes :

We may find this sample program useful:

=== HOMEWORK ===
- download the Trees project
- run it and test whether it seems to work correctly
- draw the Formula Tree that is stored in the program
- change the Formula Tree so it represents 314x + 159y
- Check that it correctly EVALUATES the tree when x=118 and y=78


What is Augmented Intelligence? - 13 Mar 2019

and then discuss Augmented Intelligence and Augmented Reality.

We may also watch this video:


Schedule Program + Test - 5-13 Mar 2019


Read the notes at the end of the sample program.

We will have a WRITTEN TEST on Fri 15 Mar
(the test is postponed due to the early dismissal on Wednesday).
This is an OPEN BOOK test, but only PAPER - no computers
You may print out anything you wish to bring with you -
for example the Scheduling program that you are writing.
You may bring any other notes you wish, but only on paper.


[HL] Binary Search Trees - 4 Mar 2019

We will continue discussing Trees, specifically Binary Search Trees.
Download this program: 




Errors and Testing and Debugging - 1 Mar 2019

  • Black-box testing = running a program and testing it
                                without reading the programming code

  • White-box testing = testing after reading the programming code

  • Data dump = have the program print out intermediate values
                         while the program is running

  • Trace tools = using the IDE to follow the execution of the program
                          step-by-step

  • Break points = make the program PAUSE at specific commands
We will do some debugging in our KinoSeats program,
aiming at making a better program that looks more or less
like this web-page: https://www.cinestar.de/kino-frankfurt-main-metropolis


More Errors - 28 Feb 2019

- The programmer should not type in 10 reservations for testing 
    every time they run the program.  Can we make a button that
    automatically writes test data into the program?

- The user types in two reservations BEFORE loading the old data
  from the disk file.  What happens if they LOAD after typing in some reservations?
  If it's okay, then fine.  We need to test this.
  If it causes an ERROR, how can we fix it?

- What if the user accidentally saves a different name into a seat
  that was already reserved.  Is there an UNDO function?  If not,
  how can we create one?

- Customer names are nice, but we have no CONTACT information
  saved.  We need to at least save an email address for each customer.
  After inputting the email addresses, we need to save them in a disk file.

- How can we prevent the user from making stupid mistakes,
   like typing the email address in the name field?

=== Here are some standard WHAT-IF ideas ===

-  Input VALIDATION loop - repeat the input over and over again
   until VALID data is obtained

- Input VERIFICATION - asking "are you sure" after input

- LOGGING input and permitting UNDO to return to 
   a previous VALID configuration

- DEFAULT test data - load this AUTOMATICALLY when
   the program runs - could be from a DISK FILE or
   from a method in the program

- TRY-CATCH construct - can react to any EXCEPTION
   Usually only displays a warning, as it cannot FIX the problem
    and then RESUME


Errors and Files - 27 Feb 2019

== HOMEWORK ==
Fix the LOAD method so that it checks for conflicts and
warns the user - asking whether it should keep the
old reservation or keep the new reservation.

Here is a partial solution, but it needs more in the ELSE part:

        try {
            BufferedReader info = new BufferedReader(new FileReader("kino.txt"));
            while (info.ready()) {
                int row = Integer.parseInt(info.readLine());
                int seat = Integer.parseInt(info.readLine());
                String customer = info.readLine();
                if(names[row][seat]==null)
                {
                  names[row][seat] = customer;
                  buttons[row][seat].setText("X");
                }
                else
                {
                    output("CONFLICT");
                }
            }
            info.close();
        } catch (IOException ex) {
            output(ex.toString());
        }
================

You can download this project:
http://ibcomp.fis.edu/2018/ib/kinoseats2.zip

Consider the following problem situations:

- The programmer should not type in 10 reservations for testing 
    every time they run the program.  Can we make a button that
    automatically writes test data into the program?

- The user types in two reservations BEFORE loading the old data
  from the disk file.  What happens if they LOAD after typing in some reservations?
  If it's okay, then fine.  We need to test this.
  If it causes an ERROR, how can we fix it?

- What if the user accidentally saves a different name into a seat
  that was already reserved.  Is there an UNDO function?  If not,
  how can we create one?

- Customer names are nice, but we have no CONTACT information
  saved.  We need to at least save an email address for each customer.
  After inputting the email addresses, we need to save them in a disk file.

Error Handling - Exceptions and Testing - 25 Feb 2019

We will discuss how to SAVE and LOAD the Kino Reservations,
and how to create TEST CASES for the program.


GUIkino2 and Trees1 - 15 Feb 2019

Download this project:

(1) We need to see how to complete #4 and #5 from yesterday.

(2) HL students - 
    look at the PROPER way to TRAVERSE the tree,
    and use this idea to output all the PRIME FACTORS


Multi-Buttons Programs - 14 Feb 2019

[SL] students 
Add the following methods to your KinoSeats program.
Figure out what each method does, add an appropriate button
and then type in the code and test it.

(1)

(2)
After you have these working correctly, 
add buttons and methods for each of the following - 
do as many as you can during class today:

(3) Input the number of a row - between 0 and 9 -
and count the number of occupied seats in that row.

(4) Search for a free seat that does NOT have 
a person sitting in front of that seat.

(5) Change the seat reservation method (in actionPerformed)
so that it asks how many seats you want.
So if the user clicks on button[3][5], and the user
says they want 3 seats, then it reserves
[3][5] and also [3][6] and also [3][7].  
But it should NOT reserve 3 seats if any of those seats
already has a reserved occupant.
----------------

[HL] Students - 
The teacher will continue explaining TREES and you
will make a program involving trees.

/******************************************************\

public class Trees1 extends javax.swing.JFrame {

    public class Node
    {
        int value = 0;
        Node leftChild ;
        Node rightChild ;
    }
    
    Node root;
    
    public Trees1() {
        initComponents();
        makeTree(456);
    }
    
    public void makeTree(int num)
    {
        root = new Node();
        root.value = 456;
        
        root.leftChild = new Node();
        root.leftChild.value = 6;
        
        root.rightChild = new Node();
        root.rightChild.value = 76;
        
        root.leftChild.leftChild = new Node();
        root.leftChild.leftChild.value = 2;
        
        root.leftChild.rightChild = new Node();
        root.leftChild.rightChild.value = 3;
        
        root.rightChild.leftChild = new Node();
        root.rightChild.leftChild.value = 2;
        
        root.rightChild.rightChild = new Node();
        root.rightChild.rightChild.value = 38;
        
        root.rightChild.rightChild.leftChild = new Node();
        root.rightChild.rightChild.leftChild.value = 19;
        
        root.rightChild.rightChild.rightChild = new Node();
        root.rightChild.rightChild.rightChild.value = 2;
    }

    public void findFactor()
    {
       int factor = Integer.parseInt( input("Possible factor?"));
       
       Node here = root;

       while(here!=null)
       {
           if(here.value==factor)
           {
               output("Found it");
           }
           else
           {
               here = here.rightChild;
           }
       }
       
    }

  . . . . . . . . . .  rest of program . . . . . . . . 

\************************************************************/

[HL] Trees - 13 Feb 2019

Here are some introductory notes about TREES.

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


Automating GUI Objects - 12 Feb 2019

Look at this web-site for Kino reservations: https://www.kino.de/kinoprogramm/stadt/frankfurt-am-main/
We will start with this program:   http://ibcomp.fis.edu/2018/ib/KinoSeats.zip


Test on OS and Platforms - 11 Feb 2019


IoT Discussion and Test Review - 8 Feb 2019



More Research - 6 Feb 2019

USB Basics - Here is a short article covering the basics of USB:

Continue your research about OS for IoT:
***************************************************************
*** Research Assignment (preparing for test)            ***
*** The Internet of Things will require STANDARDS ***
*** and probably an Operating System that will be   ***
*** the same for many of these Things.                    ***
*** - What is this OS likely to be?                             ***
*** - What already exists?                                         ***
*** - Will there be different OSs for different             *** 
***     kinds of Things, like:                                           ***
***     Transportation, Manufacturing, Entertainment...  ***
*** . Find out as much as you can in a couple hours .   ***
*** . We will discuss your findings on Friday.                ***
***************************************************************

We will discuss your discoveries on Friday.


== Review for Monday's Test ==

The test on Monday will cover:
- Section 10.1 and 10.2 in your textbook
- IB Notes 2.1.6, 2.1.7, 2.1.8, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5
- For HL students also 6.1.7

Here are some review questions for your Monday Test:
(1) Explain why a PLATFORM is not the same as an Operating System.
(2) Explain the difference between CLI and GUI, including a specific example.
(3) Explain how Multi-tasking and Memory-Management are connected,
      and then explain how they are separate.
(4) Describe a specific example of a program that is an APPLICATION,
      but is not part of the Operating System.
     Then describe a specific example of a program that is part
      of the Operating System, but is not an APPLICATION.
(5) Explain how tasks can "run in the background",
       including a specific example of a background task.
(6) Explain what Virtual Memory is, why it is important,
       and how it works.
(7)  State NORMAL numbers for each of the following :
     (a) RAM in a laptop (notebook)
     (b) secondary storage in a Smartphone
     (c) bandwidth in a home WIFI network
     (d) size of a Hard-Disk-Drive in a personal computer
(8) Describe 3 different computing PLATFORMS that 
       might be owned by a 17 year old student.
(9) (a)  Describe FOUR important responsibilities of a PC Operating System. 
      (b) Describe ONE important feature of an OS on a DIFFERENT PLATFORM than a PC.
(10) Explain why it is desirable to have very similar Operating Systems on devices that
        have significantly different hardware components.
(11) (a) Explain what the INTERNET OF THINGS is,
             including 2 specific examples of IoT devices.
        (b) Explain why the IoT will require a STANDARD OS on many devices.
        (c) Explain why the IoT will likely have several different OS STANDARDS,
              rather than one single standard.
        (d) Explain why USB is probably NOT a significant part of Io
= HL Only =
(12) Explain what an OS POLICY is, including one specific example.
(14) Explain why question #13 is missing.
(15) Explain what TASKS are, including where you might see them in a PC.
(16) Explain the difference between INTERRUPTS and POLLING 
        communication protocols.


Continue Future OS and Platforms - 4-5 Feb 2019

**************************************************************
*** Research Assignment (preparing for test)            ***
*** The Internet of Things will require STANDARDS ***
*** and probably an Operating System that will be   ***
*** the same for many of these Things.                    ***
*** - What is this OS likely to be?                             ***
*** - What already exists?                                         ***
*** - Will there be different OSs for different             *** 
***     kinds of Things, like:                                           ***
***     Transportation, Manufacturing, Entertainment...  ***
*** . Find out as much as you can in a couple hours .   ***
*** . We will discuss your findings on Friday.                ***
***************************************************************

HOMEWORK - USB C vs USB B vs USB A

===== Test Announcemnt =====
We will have a written test about 
Operating Systems and Platforms
on Mon 11 Feb 2019
==========================

You can learn ALL about USB at HowStuffWorks:



==========================

What about a "smart home"?  Does it use an OS?

What about a "self driving car"?  Does/will it use an OS?

Does the Web have AN OS?

Will the Internet Of Things have an OS?

==========================

KAI OS

Wearable Tech

AI in the System

Chrome OS Tablet Future
Disappointing Pixel Slate
- How significant is USB C?
- If you have a new MacBook with USB C, 
  does it stop you from doing some things?
- How is Chrome OS significantly different from
  MacOS, Windows, Androd and IOS?

Can we do AI without talking or hearing?  ARTIFICIAL INTELLIGENCE = SW for small devices, HW for big devices
Can computers do talking and hearing without AI?
Does a robot have an OS?
Does a wearable "smart watch" have an OS?
Does a modern TV contain an OS?
Does a Playstation contain an OS?

What about a "smart home"?  Does it use an OS?
What about a "self driving car"?  Does/will it use an OS?

Does the Web have AN OS?
Will the Internet Of Things have an OS?


[HL] Topic 6.1.7 - 1 Feb 2019


6.1.7

Outline OS resource management techniques: scheduling, policies, multitasking, virtual memory, paging, interrupt, polling.

2

Technical details as to how these are carried out will not be required, but it is expected that students will be familiar with these techniques and understand when and why they are used.

Scheduling - keep a list of tasks or utilities that must run periodically :
-  HDD scans
-  backups
-  virus scans

Policies - allowing/denying appropriate access levels according to users' credentials - e.g. not every user is permitted to format a disk drive
or delete from the OS folder


Paging - this is a simple method for allocating RAM in large blocks, rather than allocating small amounts.


Multitasking - OS must coordinate multiple tasks by:
  "time-slicing" to allow one application to use the CPU for a short
   period, like 1 millisecond, then switch to a different application
   and run that for 1 ms, then switch again to the next application


Virtual memory -  when RAM is full, the OS "swaps" the less urgent tasks
  out of RAM and places them in "virtual memory" on the disk drive,
  then swaps them back into RAM when needed


Interrupt handling - the OS must respond to Interrupt signals from peripheral devices.  Some interrupts have a higher priority than others - for example the Power Switch is not a physical device, but sends an interrupt asking the OS to shut-down.  Then the OS will ask for confirmation from the user. But the response has a high priority, and would work even when another task has locked up the CPU in an infinite loop.


Polling - rather than waiting for an interrupt from a peripheral, some peripherals are handle by POLLING - that means a query is sent to the peripheral to ask whether the peripheral needs service.  This is typical for a sensor or actuator involved in time-critical task like medical monitoring devices or robots.



We will investigate this program:

/**************************************************\
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        int size = Integer.parseInt(jTextField1.getText());
        double [][] nums = new double[size][2];
        for(int x = 1; x < size; x++)
        {
            double y = 1.0/x;
            nums[x][0] = x;
            nums[x][1] = y;
        }
        double sum = 0;
        for(int x = 0; x < size; x++)
        {
            sum = sum + nums[x][1];
        }    
        jTextField2.setText(sum+"");
    }                                        

\**************************************************/


Future OS and Devices - 31 Jan 2019

KAI OS

Wearable Tech

AI in the System

Can we do AI without talking or hearing?
Can we do talking and hearing without AI?
Does a robot have an OS?
Does a wearable "smart watch" have an OS?
Does a modern TV contain an OS?
Does a Playstation contain an OS?

What about a "smart home"?  Does it use an OS?
What about a "self driving car"?  Does it use 


Operating Systems = Topic 6 : 29-30 Jan 2019

History of Operating Systems

IB Topic 6

Another Teacher's Notes about Topic 6

Today we will look at the Command Line Terminal in Mac OS.


More About Platforms - 24-25 Jan 2019

 Topic 2 :    Systems/Topic2.html






 Solid State (Flash) Drive : https://www.youtube.com/watch?v=spiw1hQrW-w



Continue Operating Systems and Platforms - 23 Jan 2019

 10.1 and 10.2 in Comp Sci Illumin Book

 Topic 2 :    Systems/Topic2.html


[HL] Test Topic 7 - 22 Jan 2019

Test


Study Day - 21 Jan 2019

SL students - continue reading 10.1 and 10.2 in Comp Sci Illumin Book

HL students - Reminder that you have a TEST tomorrow about Topic 7
and you may wish to study for that:


On Wednesday, we will continue discussing Operating Systems and Platforms and Cross-Platform Compatibility.

Starting Topic 2 - 17-18 Jan 2019

== HOMEWORK ==
Read 10.1 and 10.2 in your textbook,
by Tuesday, but get started on the weekend
===============

Taking a break from programming.

We will spend a couple weeks discussing Topic 2 - Computer Organization.
Here are some notes that we will be using:
Systems/Topic2.html
We will discuss PLATFORMS and OPERATING SYSTEMS (2.1.6) today and tomorrow.

You don't need to read it all today.
You can start by watching some videos.
Intro to OS : https://www.youtube.com/watch?v=pTdSs8kQqSA (review)
Java Platform : https://www.youtube.com/watch?v=2Xa3Y4xz8_s (review + OS)
Desktop Platforms: https://www.youtube.com/watch?v=FUDw5hS8LUU (OS)


Quiz about Guard House Program - 15 Jan 2019

First - brief discussion of the Extended Essay

Interested in an Extended Essay in Computer Science?

Try reading the information on this web-site:

http://ib.compscihub.net/ee

Subject Specific Info for IB Comp Sci
https://ibpublishing.ibo.org/extendedessay/apps/dpapp/guidance.html?doc=d_0_eeyyy_gui_1602_1_e&part=5&chapter=4

Read the explanation of "Computer Science" in Wikipedia:
https://en.wikipedia.org/wiki/Computer_science

Second - Quiz about the Guard House Program


Tracking People on Campus - 14 Jan 2019

If our ID scanners at the school entrance worked sensibly,
the algorithm for storing names of people on campus would
look something like this:

=============================================
= Entering =
- scan the card (input the name)
- add the name to the ENTERED list (a LinkedList)
- open the gate

= Leaving =
- scan the card (input the name)
- check whether the name appears in the ENTERED list
- if name is found
  -  remove the name from the list
  -  open the gate
- it name is not found
  - do not open the gate
  - sound a security alarm
  - let the guard deal with the problem
=============================================

There are lots of other issues - which is probably why the gates don't work.
For example:
-  what if a delivery person arrives and does not have an ID card
-  what if a student loses their ID card, then they cannot get out
-  what do we do with a bus full of students - should they get off the bus,
    go through the security gate - and if one student fails, must the bus wait?
- what if a student sneaks off campus and we finish the day
   with one student name still in the list?

We will write a simple program to deal with the ENTERING and LEAVING
algorithms written above - ignore the other issues for now.

Maybe we will not have a quiz today, but for sure tomorrow.

More Algorithms in LinkedLists - 11 Jan 2019

(1) Brief quiz (6 minutes)

(2) In the same LinkedLIst2 program that we have been using,
      make Buttons and write methods to do each of the following algorithms.
      Do as many as you can in 40 min in class, plus 30 minutes at home.
      It's not necessary to spend more time than that.

      In each case, assume that the LinkedList already contains some words.
  • Count the NUMBER of times that the word "help" 
    appears in the list.  Print the resulting number.
    This should work even if the list is not sorted,
    and it should print 0 if "help" does not appear in the list.
  • Print all the words that start with the letter "D".
  • Assume the list is already sorted alphabetically.
    Scan through the list and check each word and the following word.
    If the two words match, remove the second copy of the word.
    if you do this correctly, it would remove all the duplicates,
    even if there are 3 words in a row that are identical.
  • Exchange the first word and the last word.
  • Remove the last 3 words in the list.
  • Input two words from the user.  If these are found in the LinkedList,
    then exchange their positions.

[HL] Finishing Topic 7 - 10 Jan 2019


Here is a practice quiz from Mr Brooke:

*** TEST ANNOUNCEMENT ***
We will have an HL Test on Tuesday 22 Jan about Topic 7.
This will be a written test - no computers.

You can study for the test by reading the notes above,
and making sure that you understand the following vocabulary:

Control System
Embedded System
IPO = Input-Processing-Output
Microprocessor
Sensor
Actuator
Transducer
Analog
Digital
ADC , DAC
Positive Feedback
Negative Feedback
GPS
Smartphone
CCTV
Distributed System
Internet of Things
Autonomous Agent

You might also want to look back through the days of [HL] meetings
listed on this blog to remind yourself of examples we discussed, like:

Automatic Doors
Elevators
Washing Machines
Fire alarms
etc.


Sorting a LinkedList - 9 Jan 2018

We will continue with the same sample program, but we will add
 a SORT button that sorts a list that is not in order.

In case you took poor notes, you might try this code - 
but it contains one error that you will need to fix.

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      for(int passes = 0; passes < notes.size(); passes++)
      {
         for (int x = 0; x < notes.size() - 1; x++) 
         {
            if (notes.get(x).compareTo(notes.get(x + 1)) > 0) 
            {
                String first = notes.get(x);
                String second = notes.get(x+1);
                
                notes.remove(x);
                notes.remove(x+1);
                                
                notes.add(x,first);
                notes.add(x,second);
            }            
         }
      }

More about LinkedList - 7-8 Jan 2018

Notes about LinkedList: 

We will use .add(int, data) to insert and sort in a LinkedList,
using this sample program:

Here is a short video explaining the LOGIC of inserting in a LinkedList:


Removing, Searching and Inserting in a LinkedList - 12 Dec 2018

We will continue with the Appointments program (below),
but we will put in different data.

Starting with the program from yesterday, do the following:
    //  Copy all the changes from paper into your program
    //  Test it
    //  Fix the [remove] button
    //  SYNCHRONIZE the display after every operation
    //  Fix the [Search] to  use the top box for input
    //  Make the [remove] button work like this:
    //      - it SEARCHES for the text in the upper box
    //      - when it finds it, it REMOVES that record
    

 

OOP Vocabulary - 11 Dec 2018

== HOMEWORK ==
Create a good [REMOVE] button for the appointments program (below)
===============

This week we will focus in the VOCABULARY used in OOP (Object Oriented Programming).
For example, what is a MUTATOR and an ACCESSOR?

We will see and change/fix some sample programs, as well as reading some brief
documents about OOP.  Looking forward to a MULTIPLE CHOICE TEST
in January.

Here are some notes that might help:

We will discuss the following program:
Netbeans/Appointments.zip

Details of LinkedList commands are contained in:
jets.pdf





Number Formatting - 3 Dec 2018

In case you want to control the formatting of numeric output -
like specifying a number of decimal places -
you can do it like this:

        double x1 = ( -B + Math.sqrt(B*B-4*A*C) ) / (2*A);
        double x2 = ( -B - Math.sqrt(B*B-4*A*C) ) / (2*A);   

        java.text.DecimalFormat df = new java.text.DecimalFormat("0.000");

        jTextField4.setText(df.format(x1));
        jTextField5.setText(df.format(x2));
 
This makes the output easier to read and saves space in the interface.

EdTools ver 2 - 29 Nov 2018

Download this new copy of EdTools (or use your own copy).

We will discuss Error Handling in detail.

== Programming Assignment ==
Your assignment is to create an EdTools program with 4 tools.
These must be different than the example the teacher wrote.
Your program must contain 
- at least 2 math calculation tools 
- two other NON-MATH data tools that provide some useful
   information retrieval

For the math problems, you can look in your math textbook
for sample problems.  For example:
- Arithmetic, Geometric sequences
- logarithms

For the NON-MATH data tools, some ideas are:
- looking up capitals of countries
- looking up important historical dates, like:
    What happened in 1953?  White Christmas premiered
    What happened in 1940?  McDonald's opened
- Find distances between cities
    Frankfurt to London = 770 km
    Usingen to Oberursel = 19 km
- Music Trivia
     Beatles = John, Paul, George, Ringo
     Bob Dylan = won the Nobel Prize for Literature

Your program must be structured like the EdTools example,
with a MAIN window with 4 buttons, and separate CLASSES
that pop up when a button is pressed.

This assignment is due Friday 7 Dec 2018 at 18:00

If you finish early, you can always improve your program by:
- adding more error handling
- making pretty interfaces with colors and pictures
- nicer formatting of the answers, like rounding numbers to 
   3 decimal places


[HL] Embedded Processors - 28 Nov 2018


Analog vs Digital

Satellite Tracking for Criminals

Feedback

IB Syllabus Notes Topic 7


EdTools OOP Project - 27 Nov 2018

Download this program:

HOMEWORK - bring this to class on Thursday
    Add the QUADRATIC class.  Here is a PLAN:

     A [               ]
     B [               ]
     C [                ]

       [Solve ax^2 + bx + c = 0]

       X1 [                       ]
       X2 [                       ]

 -- use the quadratic formula

       check that A is not 0

       check that B is not blank --> use 0

       check that C is not blank --> use 0

           answer1 = (-b + Math.sqrt( Math.pow(b,2) - 4*a*c )) / (2*a)

           answer2 = (-b - Math.sqrt( Math.pow(b,2) - 4*a*c )) / (2*a)



Last Scoreboards Day - 26 Nov 2018

We will spend one last day discussing this Scoreboards program:
http://ibcomp.fis.edu/2018/ib/OOP23.zip


OOP Scoreboards - 19-21 Nov 2018

We will start with this scoreboard CLASS.

Then we will be working on this scoreboard program:
NetBeans/OOP2.zip

Change this program to fit 15 or 16 scoreboards
on the screen.  Either 5 rows of 3 or 4 rows of 4,
depending on what you prefer.  Make sure they are
all different colors, and that all the text is readable.
AFTER you have finished this you need to add
one more item to the Scoreboard class - the Scoreboard
should display a date, next to the Title.  This should
be relatively short, like 12/25 or 25.12 .  It should
be set by the Startup class, when it creates the Scoreboards.


Test - 16 Nov 2018


Review for Test - 15 Nov 2018

The test will include questions about:
-  machine language
-  binary, hexadecimal and decimal
-  logic gates and circuits
-  Boolean algebra

Review Boolean Algebra:
User your book - Chapter 4 practice questions

Review circuits: 

Review binary:

Review Machine Language:
Use the notes from Oct 24 and 25


[HL] Embedded Processors - Topic 7 - 14 Nov 2018



We will discuss these notes:

=== HOMEWORK ===
Read the notes above (skip Feedback).
We will continue discussing this during the next HL meeting.


Boolean Algebra - 13 Nov 2018

We will discuss the questions in this document:


Boolean Algebra - 12 Nov 2018

We will discuss the questions in this document:

You should read (at least briefly) sections 4.1 , 4.2 , and 4.4 in your book.

You may find this video helpful (optional)

Volleyball - 9 Nov 2018

Class was cancelled to watch the volleyball tournament.
Our upcoming test will be postponed until Friday16 Nov.


Logic Circuits Practice - 7 Nov 2018

Answer the questions here:

=== HOMEWORK ===
Complete pages 1 and 2 in the notes above.
We will discuss p. 3 in class on Friday.


Logic Circuits - 5-6 Nov 2018



[HL] Internet of Things and other Embedded Processors - 1 Nov 2018


We will discuss the Internet of Things and Smart Home Technology




Hexadecimal and Binary - 31 Oct 2018

Here is a video about an old, old computer:


More Binary - 30 Oct 2018

Using this practice program:
we will do a quiz.

We will continue these notes about binary storage:
http://ibcomp.fis.edu/239179/ibcomp/numbers/codes.html

Here is a video about an old, old computer:
https://www.youtube.com/watch?v=DPioENtAHuY&feature=related

Use a HEX EDITOR to do the Practice Questions in the page above. You can use this online HEX editor:
https://hex-works.com/eng

If you are interested in MIME types, read the first 4 paragraphs here:
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Configuring_server_MIME_types

== HOMEWORK ==
Read these notes about BINARY:


Better Assembly Language - 29 Oct 2018

We will investigate this program in the Little Man Emulator:
// ADD UP ODD NUMBERS
       BRA 6
       DAT 1
       DAT 2
       DAT 0
       DAT 1
       DAT 51
       LDA 3
       ADD 4
       STA 3
       OUT 3
       LDA 4
       ADD 2
       STA 4
       SUB 5
       BRZ 16
       BRA 6
       HLT
.END
// Using Line Labels (like variables)
       BRA START
ONE     DAT 1
TWO     DAT 2
SUM     DAT 0
X         DAT 1
MAX     DAT 51
START  LDA SUM
          ADD X
          STA SUM
          OUT SUM
          LDA X
          ADD TWO
          STA X
          SUB MAX
          BRZ QUIT
          BRA START
QUIT    HLT
.END


== Introduction to Binary ==


We will discuss these notes about binary storage:
http://ibcomp.fis.edu/239179/ibcomp/numbers/codes.html

Here is some FUN practice with binary:
http://games.penjee.com/binary-bonanza/


Assembly Language Programming - 25 Oct 2018

We will write some Assembly Language program for some of the following tasks:

- display a message, stopping at a 0 byte
- multiply 2 numbers by adding repeatedly
- count 0 to 59 and then back to 0 to 59 and then back to 0...
- calculate x^2 - 5x + 3 


*** HOMEWORK - READ Section 5.2 in your textbook ***

CPU, RAM and ROM - 24 Oct 2018

== CPU BASICS ==

Watch this video (at least the first half):

How a CPU Works  (nice graphics)

We will be discussing these notes:

Then use the CPU Emulator:
http://peterhigginson.co.uk/LMC/

You will need this for the emulator:
       LDA 4
       OTC
       ADD 5
       BRA 1
       DAT 65
       DAT 1

HOMEWORK : Read section 5.2 up to and including RAM and ROM


Hardware Questions - 23 Oct 2018

We will discuss the questions from last Friday.

Answers are in this Google Doc:


[HL] Elevator Logic - 22 Oct 2018

We will discuss the LOGIC of elevators - specifically:
- how to decide whether the elevator should travel UP or DOWN
- how to decide whether the elevator should STOP when it is passing a floor
- when should lights be switched ON and OFF

We will try to make a plan for where the SENSORS and ACTUATORS belong in the elevator system.

What OTHER sensors matter to an elevator, besides buttons and floor indicators?



Some Hardware Vocabulary Investigation - 19 Oct 2018

Use Google, Wikipedia, Amazon or any other online sources to answer the following questions.  
You may also wish to use your textbook : Comp Sci Illumin Book
You can type your answers in a word-processor and we will discuss them in class on Tuesday. 

1. Find 2 advantages and 2 disadvantages of buying an SSD 
    (Solid State Drive) instead of an HDD (Hard Disk Drive).

2. At Amazon or some other similar site, find the LARGEST
    AMOUNT of RAM that you can purchase in a new computer.

3. If a computer does NOT contain a "graphics card" - for example,
    most laptops - what hardware does it contain for displaying
    graphics on the screen?

4. Since an 8X DVD drive runs 8 times faster than a normal
    movie, what advantage does the 8X drive offer over a
    slower optical drive?  You don't need it for showing movies.

5. What do the letters "a/g/n" stand for in the 802.11 specification?

6. Lithium Ion batteries are used in laptops.  How does this differ
    from a normal AA battery that is not-rechargeable?

7.  Find a new laptop computer that you can buy with the highest
     possible screen resolution (e.g. larger than 1366x768).

8. Predict the likely capacity of a Hard Disk Drive in the year 2020,
    including a reason for your prediction.

9. Use this web-site: https://www.cpubenchmark.net/ , 
    or a different site if you wish, to find a CPU with a
    VERY HIGH CLOCK SPEED - e.g. over 3 GHz

10.  Describe the equipment required if you wish to watch
     YouTube videos on a large screen (60") TV.  Include any
     cables or other special devices needed.

11.  Many modern laptops are sold without a DVD drive.
      In the past, a DVD drive was considered essential.
      Explain why DVD drives are no longer essential.

12. Find normal data-transfer speeds for each of the following:
      - SATA hard-disk
      - USB
      - FSB
      - WIFI

 

More Hardware - 18 Oct 2018

We will discuss the hardware items described in section 5.1
in your textbook.

Hardware - 17 Oct 2018

== HOMEWORK ==

After finishing your test, you should start reading section 5.1 in your textbook.  

You should bring the textbook to class tomorrow - after that, you may leave it at home.


Review for Wednesday's Test - 15 Oct 2018

Review for Wednesday's test.

*** TEST ***
We will have a 30 min written TEST on Wednesday, similar to the quizzes
that we had previously.  You will need to examine Java program,
predict what they will print, or fix errors.  You could prepare by
working with a partner to look at previous programs, make changes,
and have the partner guess what changes need fixing. 


More About Standard Classes - 12 Oct 2018

The Math class is contained as a standard part of Java -
in the main Java package, so you can use it's methods
without stating the name of the package.

A list of all the most commonly used Math function is found

Programs that solve mathematics problems generally use both
the Math class methods and the Format methods in the java.text package.

Here is a Java example:


Here is the code for this example:

/*** Table of Values *************************************
Marla is a math student.  She needs to draw graphs and analyse them.
This is easier with a table of values for the function.
The TAB character \t makes the columns line up properly.
**********************************************************/

public class TableValues
{
  public TableValues()
  {
    System.out.println(" x      y");
    for(double x = 0; x <= 5; x = x + 0.5)
    {
      double y = 3*x*x - 7*x + 2; 
      System.out.println(x + "\t" + y);
    }  
  }
  
  public static void main(String[] args)
  {  new TableValues();  }
}

//*******************************************************//

We will discuss how to make a NICELY FORMATTED table.

You can use this program, with some alterations, to solve other equations, like:

   y = x^4 - 8x^2 + 15
   y = sin(x) - cos(x)
   y = x - sqrt(x+1) 

Or pretty much any other equation in your math textbook.

Using Standard Classes and Objects - 11 Oct 2018

We will be working through some of the notes
and exercises in Chapter 3 of this book:
https://kea.nu/files/textbooks/intro.pdf 3.4-3.6
You should read sections 3.4-3.6

We will discuss the following code:

   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       String price = jTextField1.getText();
       double money = Double.parseDouble(price);
       double tax = money*0.18;
       double total = money + tax;

       DecimalFormat df = new DecimalFormat("0.00");
 
       jTextField2.setText(""+df.format(total));
   }
   
   // HOMEWORK:
      //   Make 4 boxes for 4 prices
      //   a Button ADDS UP the 4 prices
      //   and puts the result in a 5th box
      //   nicely formatted to 2 decimal places

Another Example 

The following code makes a JButton twice as wide.

   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       System.out.println(jButton1.getWidth());
       int w = jButton1.getWidth();
       int h = jButton1.getHeight();
       int x = jButton1.getX();
       int y = jButton1.getY();
       w = 2*w;
       jButton1.setBounds(x,y,w,h);
       
       // finish this so the second button moves below
       // but does not change its size
   }      

If there is another JButton next to it,
the code needs to move that JButton down
to the next line, below this JButton.
Finish the code to do that.


[HL] Elevator Simulation - 10 Oct 2018

We will look at whether some students produced good simulations.
Otherwise we will use this one:


Times in Strings - 9 Oct 2018

*** Written Test - all the Java we have learned - Wed 17 Oct ***

Today we will discuss yesterday's program.

Then we will write a program that can find the 
elapsed time between a start and finish time -


Dates in Strings - 8 Oct 2018



String Practice - 24-26 Sep 2018

Here are some notes about String commands:
http://ibcomp.fis.edu/Strings/howto.htm

Here are some practice programs involving String variables:

== HOMEWORK ==
Spend 30 minutes programming solutions for
practice #1 and #2.  If you don't finish, that's okay.
We will finish this in the next class meeting.


String Commands - 21 Sep 2018

Reading:  p.118-121 in the textbook

Here are some notes about String commands:
http://ibcomp.fis.edu/Strings/howto.htm

Today we will write a program for a cafeteria cash register:

//==========================================

  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
 
    String food, item, more ;
    double price, total;
  
    do                       // repeat for each new customer
    { total = 0.00;
      do                            
      {                          // repeat for each food item
        food = input("Food item");
        if( food.equals("ha") )       // hamburger
        {  price = 3.50; }
        else if (food.equals("ff"))   // french fries
        {  price = 1.75; }
        else if (food.equals("ap"))   // apple
        {  price = 0.90; }
        else if (food.equals("dr"))   // drink
        {  price = 1.40; }
        else 
        {  price = 0.00; }            // unknown item
        list1.add(food + "\t" + price);
        total = total + price;      
      } while(!food.equals(""));  // press ENTER after last item
      
      list1.add("Total = " + total);
      more = input("Next customer (or type 'quit')");
    } while (!more.equals("quit"));
  
    }                                        

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

//================================================


More String Arrays - 20 Sep 2018

Searching for
-  specific names
-  names with a specific starting letter
-  names starting with a specific 3 letters

Adding TIMES at the beginning of each entry

Extracting times before 12:00


[HL] Elevator Rules - 19 Sep 2018

What rules must be implemented as decisions in the embedded controller?

We will try to make an Elevator Simulator, like this one:

Homework:  In NetBeans, make an Elevator Simulator,
with BETTER RULES than the online link (above).
This is due for the next [HL] class.
Don't spend more than 2 hours on this.
You will not complete it (too difficult)
but get as far as you can in 2 hours.
Bring QUESTIONS to class on 10 Oct.

String Arrays - 18 Sep 2018

Download this program:

We will write a program to keep back of students who
leave school in the middle of the day.  A basic starting
version is in the .zip archive - GUILeavers.


Counting in Arrays -  17 Sep 2018

Here is some Java code that simulates flipping a coin.
In this code, 1 represents heads, 0 represents tails.

     int[] coins = new int[1000];
     for(int c = 0;  c < 1000;  c++)
     {
          coins[c] = (int)Math.floor(Math.random() * 2) ;
     }

     int heads = 0;
     for(int c = 0; c < 1000; c++)
     {
            if( coins[c] == 1)
            {   heads = heads + 1; }
     }

     System.out.println( "Heads Fraction = " + (heads / 1000) );

-  Put this code into a GUI
-  Change the output to print into a JTextField
-  Make a button that counts TAILS ( value = 0 )
-  Make a button that counts "pairs" - that is 2 rolls in a row
    that are the same, like head-head or tails-tailsl
-  Make a button that counts the number of times that HHHH occurs
-  Count how many duplicates happen at the beginning


TextFields in a GUI - 14 Sep 2018

Today we will write a GUI Password program, using JTextFields for input and output.

Then we will have a Practice Quiz, so you are prepared for the 10 minute quiz on Monday.
Next week, we will have short quiz at the beginning of each class.


GUI Dice - 12 Sep 2018

We will create a GUI program - with proper windows - using this code:

        int[] dice = new int[4];
        for(int d = 0; d < 4; d++)
        {
            dice[d] = (int)(Math.floor(Math.random()*6 + 1));
        }
        int total = dice[0] + dice[1] + dice[2] + dice[3];
        String info = dice[0] + " " + dice[1] + " " + dice[2] + " " + dice[3] + "=" + total;

        list1.add(info);

The teacher will demonstrate how to create a GUI program in NetBeans.
Then you should copy the code above and create the same program.
Try to add more BUTTONS for the following :
-  clear the list box, using  list1.removeAll();
-  change the program to roll 3 dice instead of 4
-  write commands to check for DUPLICATE dice,
    and display MATCH or NO MATCH after the total
-  add a new button to roll the dice 20 times


 

More Dice Games - 11 Sep 2018

How do we check for matching dice?
What if there are LOTS of dice?  How do we find matches then?
If the goal is to roll EXACTLY ONE 6 (no pairs), what is the best number of dice to roll to maximize chances for success?


Dice Rolls with Arrays - 10 Sep 2018

public class DiceTotals {
  public DiceTotals()
  {
    int over20 = 0;  
      
    int[] dice = new int[4];  
      
    int matches = 0;    
    for(int count=1; count <= 10; count++)    
    {
        for(int d=0; d < 4; d++)
        {
            dice[d] = (int)(Math.floor(Math.random()*6) + 1);
        }
        int total = 0;
        for(int d=0; d < 4; d++)
        {
            total = total + dice[d];
        }
        for(int d=0; d < 4; d++)
        {
            System.out.print(dice[d] + "  ");
        }
        System.out.println(total);
        if(total > 20)
        {
            over20 = over20 + 1;
        }
    }
    System.out.println(">20 = " + over20 + "  fraction = " + over20/10.0);

  }
  
  public static void main(String[] args)
  {  new DiceTotals();  }    
}
//==========================================
// This program demonstrates how to use an ARRAY
// to save multiple dice rolls,  The array is DICE[].
// Loops are used to examine the dice, in this case
// adding up the TOTAL of the 4 dice.  
//
// The advantage of using an ARRAY is that it is
// very easy to change the program to roll any number
// of dice.
//
// (1) Change the program to roll 5 dice instead of 4.
//      It must still calculate a correct total.
//      Now it is much easier to get a total over 20.
//
// (2) Change the program to roll the dice 1000 times
//       instead of only 10 times.  Make sure the FRACTION
//       of rolls over 20 is still correct.
//
// (3) The teacher will lead you through several other
//       useful changes, such as:
// .      counting matches (3 2 3 4)
// .      counting 3 of a kind (5 5 6 5)
// .      counting 4 of a kind (1 1 1 1)
// .      how many times do you need to roll to get 4 of a kind?
// .......
//==========================================


More Dice Rolls - 31 Aug 2018

We will continue discussing the dice rolling program.


More About Loops - 30 Aug 2018

We will continue discussing loops, especially the rest of the programs from Monday.


[HL] Embedded Systems - 28 Aug 2018

We will discuss students' answers to these topics:

A variety of control systems should be examined such as:
- automatic doors .   Tristan Reich 
      Video - automatic doors fail
- heating systems     Benedikt + Sam
- taxi meters            Jesper + Oliver
- elevators               Andrew H + Andrew K
- washing machines  Baldur + David
                                     - process control (?? leave this out)
                                     - device drivers
- domestic robots     Lorenzo + Robert
- GPS systems         John + Julian
- traffic lights          Tristan Roemer + Louis

  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?

Loops - 27 Aug 2018

We will study the sample LOOPS programs in:


Basic Java Lessons - 24 Aug 2018

After finishing the practice programs from yesterday (below),
look at this set of Basic Java Lessons:
To run a program, you need to copy the Source Code
into a new Java Class in Netbeans.

We will start with the Passwords program.


Starting Java - 23 Aug 2018

First we will discuss the homework - adding up odd numbers in Pseudocode.

Then we will be using NetBeans to write and run Java programs.
NetBeans is a bit complex, so we will spend some time
learning how to use this tool sensibly.  

We will start with these 2 sample programs:

//========= Calculations ===========================

public class Calculations {

   public static void main(String[] args)
   {
       new Calculations();
    }
    public Calculations()
    {   System.out.println(1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9);              // multiplication
        System.out.println(3 * 3 + 4 * 4 - 5 * 5);                             // order of operations like math
        System.out.println(100 - (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)); // use parentheses when needed
        System.out.println(60 * 60 * 24 + " seconds in a day");             // this + doesn't add
        System.out.println(365 / 7 + " weeks in a year");                   // division with integers ..
        System.out.println(1 / 2 + 1 / 3 + 1 / 6);                             //  .. doesn't produce decimals
        System.out.println(1.0 / 2.0 + 1.0 / 3.0 + 1.0 / 6.0);              // use decimals to get decimals
        System.out.println("5^3 = " + Math.pow(5, 3));                       // Math.pow for power   
    }

}

/********************************************
Practice

1 - Calculate the number of hours in one year.
 
2 - Calculate 1/2 + 1/3 + 1/4 + ... + 1/9.
 
3 - By guessing and calculating, find a solution to this problem:
        X * X * X * X = 100
    You only need to get an approximate answer with 2 decimal places correct.
 
4 - A computer works at a speed of 2 GigaHertz - that means that it can do
    2 BILLION (2 000 000 000) calculations per second. 
    Calculate the number of calculations it can do in 1 minute.
  
5 - Write a command that CORRECTLY calculates a value for 20 !
*******************************************/
//==============================================


//========= Add Up Numbers =======================

public class Addup {
   public static void main(String[] args)
   {
       int sum = 0;
       
       for(int x=0; x < 10; x = x+1)
       {
          System.out.println(x);
          sum = sum + x;
       }
       
       System.out.println(sum);
   }
    
}

/******************************
This adds up the numbers 1+2+3+... ?

-  Where does it stop adding?
-  Change it to add up 1+2+3....+99+100 ==> Correct result = 5050
-  Change it to add up only the odd numbers 1+3+5+7+...+95+97+99
-  Change it to add up 5+10+15+...+95+100
-  Change it to add up 1+2+4+16+...+65536

*******************************/
//===========================================

Java Programming - 21 Aug 2018

First - turn in your homework from yesterday.

== HOMEWORK ==
//***** In Pseudocode, add up all ODD numbers up to 100 **********
//             1+3+5+7+.........+95+97+99

Now the teacher will explain what Pseudocode is, 
what does it mean in IB Computer Science,
and how to practice at :  Pseudocode 
We will discuss the programs listed below -
these are all available in the Pseudocode Tool.

//====== Calculations =========================

output "=== Simple Calculations ==="

output "Adding 1...10 = " , 1+2+3+4+5+6+7+8+9+10

output "10 Factorial = " , 1*2*3*4*5*6*7*8*9*10

output "Fractions = 1/2 + 1/4 + 1/5 = " , 1/2 + 1/4 + 1/5

output "Pythagoras = 3^2 + 4^2 = 5^2 = " , 3*3 + 4*4 , " and " , 5*5

output "Big Numbers = one trillion ^ 2 = " , 1000000000000 * 1000000000000

output "Easier big numbers = " , 2e12 * 3e12

output "10307 is not prime = " , 10307 / 11 , " * " , 11

output "15% of 12345 = " , 15/100*12345

output "Incorrect calculation = " , 1234567890 * 1234567890

output "Another error = " , 1/2 + 1/3 + 1/6

output "One more problem = " , 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1

output "And another problem = " , 3.2 – 0.3

// --- LOGIC ----------------------------------------------------

// The computer can perform more complex LOGIC

// by using BOOLEAN OPERATORS like AND and OR.


NAME = input("Type your user name")

PASSWORD = input("Type your password")


if NAME = "bozo" AND PASSWORD = "clown" then

output "Correct!"

end if


if NAME = "einstein" AND PASSWORD = "e=mc2" then

output "Correct!"

end if


if NAME = "guest" OR NAME = "trial" then

output "You will be logged in as a GUEST"

end if


//==== Adding Up Numbers =========================

// This program adds up a lot of numbers : 1 + 2 + 3 + ... + max

// ===============================================

MAX = 10

SUM = 0

loop COUNT from 0 to MAX

output COUNT

SUM = SUM + COUNT

end loop

output "Total = " , SUM


== HOMEWORK ==
Change the Adding Up program so that it adds up
all the ODD numbers smaller than 100, e.g.
1+3+5+7+....+95+97+99


System Scenarios - 20 Aug 2018

We will discuss the Smartphone scenario and the Future PCs scenario
in the Systems notes : systems/computerSystems.html

== HOMEWORK ==
Write an answer to these questions:
- Imagine that you are hired by the school as a computer systems consultant
  to implement the planned SmartPhone system for teachers at FIS.
  What questions would you ask?  What advice would you give?


Defining Computers and Computer Systems - 17 Aug 2018

Today's Assignment

 * We will discuss these notes Computer Systems Notes about computer SYSTEMS:
   systems/computerSystems.html

Homework

Robot Fails Video ; https://www.youtube.com/watch?v=COD23cVWcIo

-  Read these notes Computer Systems Notes
     systems/computerSystems.html

     and be prepared to discuss them next class. 


[HL] Embedded Control Systems - 16 Aug 2018

IB Syllabus Topic 7

7.1.1   Discuss a range of control systems.

~~~~~~~~

A variety of control systems should be examined such as:
- automatic doors .   Tristan Re
      Video - automatic doors fail
- heating systems .   Benedikt
- taxi meters           Jesper
- elevators               Andrew H
- washing machines .   Baldur
                                     - process control (?? leave this out)
                                     - device drivers
- domestic robots .   Lorenzo
- GPS systems .      John 
- traffic lights .       Tristan Roemer

. . . 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.


IB Computer Science Course Intro - 15 Aug 2018

We will look over the course, including:

- Course Overview : IB CS Overview

- Syllabus : IB CS Course Guide

- Internal Assement : Internal Assessment Java Notes 

- Exams : Notes and Review 2019

- Textbook : Comp Sci Illuminated Book

- Java Notes : Basic Java Lessons     Java Tutor      Java Book

== HOMEWORK ==

1.  Install NetBeans  
   You need to install it and bring it to class tomorrow in working condition.  You can download it at:
     https://netbeans.org/downloads/
   Choose the Java SE version (smallest download).
 -- OR --
   http://www.oracle.com/technetwork/articles/javase/jdk-netbeans-jsp-142931.html
   to download NetBeans WITH the Java JDK.
 -- OR --
   borrow a USB stick from the teacher.

2.  Bring ONE QUESTION (or more) to class about the documents above.  We will discuss these questions tomorrow.
     


[HL] Queues - 13 May 2019

Sample program:
We will work on the Waiting program, which uses the Queue class.

Notes about queues:
 

Queues in the Counselling Office

Imagine students are sitting in the counselling office on a row of chairs, waiting to talk to the counselor..  Each new student sits behind the last student.  There are 5 chairs.

>> Empty (beginning of the day)
 
:______:    :_____:    :_____:    :_____:    :_____:
   1           2          3          4          5
 
>> First student arrives (Al)
 
:__Al__:    :_____:    :_____:    :_____:    :_____:
   1           2          3          4          5
 
>> Second student arrives (Betty)
 
:__Al__:   :_Betty_:   :_____:    :_____:    :_____:
   1           2          3          4          5
 
|>> Al goes into the counselor's office
 
:______:   :_Betty_:   :_____:    :_____:    :_____:

1 2 3 4 5
 
>> Carla arrives   :______: :_Betty_: :_Carla_: :_____: :_____:

1 2 3 4 5
 
>> Doug arrives   :______: :_Betty_: :_Carla_: :_Doug_: :_____:

1 2 3 4 5
 
>> Betty goes into counselor's office   :______: :_______: :_Carla_: :_Doug_: :_____:

1 2 3 4 5
 

Question 1:  Who is "next in line" to see the counselor now?

Question 2: What happens if 2 more students come into the office?
      Where should they sit?

If the students are not very organized, or if the chairs are scattered around, or if there are lots more chairs,
it might be useful to have a computer where the students "sign in".  Then they can sit wherever they like.  
Indeed, they could go back outside for a few minutes without "losing their place."
Whenever a student leaves, the counselor presses the "next" button on the computer, 
and it tells who is next in line. 

The WAITING program uses a queue to keep track of students waiting in the counselor's office.
A queue is a FIFO data structure = First In, First Out.

Notice that the subroutines are generic – that is, the operations Initialize, EnQueue, and Dequeue would be needed in any queue in any application.  The same ideas could be used to manage a queue of patients in a doctor's office, a queue of print jobs in a print server (spooling), and in many other practical situations.

Question 3:  What is the meaning of the variables  Head and Tail?  
       
How many "chairs" does the program have?

Notice that the DeQueue command is a Function. Why? Because it outputs a name, so it returns a result. On the other hand, the EnQueue command accepts an Input Parameter – the name which is entering (input) the queue.

Question 4: It is quite possible that the Queue will overflow.  This could be solved by allocating more memory. However, as the day progresses, the data "crawls" through the queue, so even with 100 positions it is conceivable that the Tail pointer could overflow. Suggest a solution to this problem.  Which method must be changed?