AP Computer Science A

August 18 to 26, 2009.

Ch. 1: Introduction.


LNK2LRN™

Plans for the Week and Assignments:

1. Tuesday(08/18): Introduction to AP Computer Science A and Class

Expectations. HW: Get your materials for class (3-ring binder, notebook paper,

calculator, flash-drive, pens, and pencils).

2. Wednesday(08/19): Chapter 1 - History of Computers and the Internet.

HW: Study website notes and related links. Complete Handout Assignment #1,

and get materials for class.

3. Thursday(08/20): Algorithms and Programming Languages. Euclid's GCD and

Number-Base Conversion. HW: Complete Handout Assignment #2, and get

materials for class.

4. Friday(08/21): Java Programming Structure. HW: Modify, compile, and run

the program Addition.java so that it allows the user to find the sum of 3

integers. The output should be similar to "The sum of 45, 73, and 28 is 146."

Then send it to me as an email attachment, by Sunday 08/23/09, 8:00 PM.

5. Monday(08/24): Computer Labwork - Entering your first Java program

into the computer. HW: Complete Handout Assignment #4.

6. Tuesday(08/25): REVIEW for Test on Ch.1.  HW: Finish all handout

assignments and study for Test.

7. Wednesday(08/26): TEST on Ch.1 - Introduction to Computer Science.

HW: Go to web site for notes on Ch.2 - Overview of Java Programming.

Very Important: If you have any questions or were absent from class,

see me before school (8:00 - 8:30 AM), during Lunch, or after school.

Best to send an email to rpersin@fau.edu.

 

Website Notes for Ch.1 : Introduction to Computer Science.

1. Computer Science is one of the most dynamic job markets in America. It now

rivals engineering  both in number of jobs and pay. The scope of Computer

Science goes beyond merely learning applications like word processing, spread

sheets and presentation software. It focuses on the systems and programs

behind the applications.

2. Computer science can be divided into roughly three areas:

(a) Computer programming - How applications like word processors are written

(b) Operating systems - How systems are set up to control computers, such as

the Windows™ or Linux™ operating systems.

(c) Networking - Issues concerning how computers are linked together including

the Internet.

3. This course focuses mainly on Java computer programming at the Advanced

Placement Computer Science level. Students will be required to take the AP

Computer Science A test. If they pass they may receive college credit for one

semester of computer science.

4. AP scores can also be a significant factor in scholarships and college entrance.

For more information contact the American College Board.

5. Who Should Take this Class: Students with an interest in careers related to:

the computer professions, engineering, math, science, or business.

6. As we start our study of developing algorithms, we consider one of the most

fundamental problems facing any student of mathematics is finding a common

divisor of two numbers or determining if two numbers are relatively prime.

7. Euclid's Algorithm provides us with the Greatest Common Divisor or GCD.

This method is foolproof for any mechanical application of reducing a fraction.

Here is an Example:

Assume you wish to find the GCD of 2047 and 391.

(a) Divide the larger by the smaller and note the remainder: 2047/391 =

(391 X 5) + 92

(b) Divide the remainder (92) into the previous divisor (391): 391/92 =

(92 X 4) + 23

(c) Repeat steps 1 and 2 until the remainder is 1 or zero.

then Divide the remainder (23) into the previous divisor (92): 92/23 =

(23 X 4) + 0

(d) When the remainder is zero the last divisor is the GCD! 23 X 89 =2047

and 23 X 17 = 391. Therefore 89/17 = 2047/391

(e) When the remainder is 1 the two numbers have NO common divisor

and are relatively prime.

Here is another one: Assume you wish to find the GCD of 8191 and 1023.

8191/1023 = (1023 X 8) + 7

1023/7 = (7 X 146) + 1

The remainder is 1 therefore these two numbers have NO common divisor!

Another way to do this is to continue one more step until the remainder is

zero: 7/1 = (1 X 7) + 0 then check the last divisor for 1.

Either way the result is the same.

8. Base changing: To calculate a base change from base n to base 10:

  • Label each digit with it's relative npower.
  • Start from the right-most digit.
  • The right-most digit is labeled with n0
  • Increase the power by 1 as you move to the left.
  • Multiply the digit by the npower.
  • Add these up.

e.g.:

  • 1021 (base 3)
    • = 1*30 + 2*31 + 0*32 + 1*33
    • = 1*1 + 2*3 + 0*9 + 1+27
    • = 1 + 6 + 0 + 27
    • = 34 (base 10)
  • 423 (base 6)
    • = 3*60 + 2*61 + 4*62
    • = 3*1 + 2*6 + 4*36
    • = 3 + 12 + 144
    • =159 (base 10)
  • 523 (base 9)
    • = 3*90 + 2*91 + 5*92
    • = 3*1 + 2*9 + 5*81
    • = 3 + 18 + 165
    • = 186 (base 10)
  • 10011 (base 2)
    • = 1*20 + 1*21 + 0*22 + 0 * 23 + 1*24
    • = 1*1 + 1*2 + 0 *4 + 0*8 + 1*16
    • = 1 + 2 + 0 + 0 + 16
    • = 19

9. To calculate a base change from base 10 to base n:

  • List the powers of n, starting from 1, up to but not including the least

       power greater than the (base 10) number

  • Beginning with the greatest power in your list:

  • Subtract the power from the (base 10) number as many times as

       possible, incrementing that power's digit place each time you subtract

  • Move to the next power and repeat using the remainder from the above

       step until you're exhausted the remaining powers.

  • See the examples below to understand this better

e.g.:
convert 123 (base 10)

  • to base 5
    • list 1 5 25 125
    • stop because 125 >123
    • now you have 1 5 25
    • subtract 25 from 123 4 times
    • subtract 5 from 23 4 times
    • subtract 1 from 3 3 times
    • number is 443 (base 5)
  • to base 3
    • list 1 3 9 27 81 243
    • stop because 243 > 123
    • subtract 81 from 123 1 time
    • subtract 27 from 42 1 time
    • subtract 9 from 15 1 time
    • subtract 3 from 6 2 times
    • subtract 1 from 0 0 times
    • number is 11120 (base 3)
  • to base 7
    • list 1 7 49 343
    • stop because 343 > 123
    • subtract 49 from 123 2 times
    • subtract 7 from 25 3 times
    • subtract 1 from 4 4 times
    • number is 234 (base 7)
  • to base 2
    • list 1 2 4 8 16 32 64 128
    • stop because 128 > 123
    • subtract 64 from 123 1 time
    • subtract 32 from 59 1 time
    • subtract 16 from 27 1 time
    • subtract 8 from 11 1 time
    • subtract 4 from 3 0 times
    • subtract 2 from 3 1 time
    • subtract 1 from 1 1 time
    • number is 1111011 (base 2)

9. Java was created by Sun Computers and fortunately they have a number of

free tutorials available. Go here to visit the Sun Java tutorial site. Be sure to

read the sections called Getting Started and Learning the Java Language.

10. When you're ready to write a program go to the section which is called

Your First Cup of Java.

How to get Java up and running on your system.
There are two things you need to do...

  1. Go to the JCreator website and download the Sun J2SDK.
  2. Save it to your computer (the desktop is fine), then install.
  3. Installing the SDK will  set-upthe Java "compiler" and other useful tools.
  4. Now, go back to JCreator, download the 4.50 version, and install.
  5. The first time you run Jcreator, it will run you through a wizard.
  6. Just click OK along the way and you will be ready for your first program.


How to create a project, java file, compile, and run a program.
If you have JCreator up and running, then try some of the sample programs.

  1. Click File | New Project. Type the name of the project.
  2. A project will keep all of your .java file(s) together for easy management.
  3. Click File | New File.
  4. Type the name of the file (jcreator will add the required .java extension).
  5. Click OK to save the file. Now we can start typing in our Java program!
  6. Type in the source code for you Java program.
  7. Press F7 to compile your file(s).
  8. Press F5 to run your program!

Send an email to rpersin@fau.edu if you have questions.

 

 

 

JAVA RESOURCES and WEBSITES TO VISIT:

Prime Numbers

Review of Java

Elements of Java

Honda ASIMO

RPN notation

Space Invaders 30th Anniversary