JAVA METHODS A& AB BEFORE WE BEGIN… Return your Karel J. Robot book! Go to: http://www.skylit.com/javamethods Click on “students” link under downloads section Download the student disk to your student drive CHAPTER 1 Topics: - Hardware - Software and Programming overview - Computer Memory CHAPTER 1 Students will: - be able to identify and explain hardware components - explain the relationship between hardware, software, and the internet - explain what a programmer does - will convert between numbering systems - learn the significance of ASCII code HARDWARE The most important piece: Central Processing Unit (CPU) - responsible for all mathematical computations - 1995 processor -100 MegaHertz How many computations is that? Mega = 1 million 100 million per second Today’s computers – 4 GHz HARDWARE Memory – where information is stored RAM – random access memory RAM is space for CPU to read and write data RAM retrieves stored data from Hard Disk, and writes to HD to save info More RAM means less # of times to retrieve data, so your computer is faster! HARDWARE RAM cont’d: An address bus is the channel from CPU to RAM – it sometimes can limit information processing! - it’s random because any piece of data can be returned in a constant time, regardless of physical location - not true for a magnetic discs (like a Hard Disk) or optical discs they rely on moving parts, and retrieval time will depend on the location of the previous item found Thus, the less we access it, the better! HARDWARE Hard Disk Memory stored on magnetic discs Discs are stacked on each other, and rotate so that fixed “heads” can retrieve data Stores large amounts of data More RPM’s = faster retrieval HARDWARE I/O devices I/O is used to describe anything that has input or output Input – keyboard, mouse, gamepad Output – monitor, speakers HARDWARE PC Board = printed circuit board - a.k.a. motherboard Brings it all together Holds CPU, memory, I/O devices Also holds CMOS Holds basic instructions computer needs to initialize hardware and bootup Does not require external power SOFTWARE The stuff that we write! It can be thought of as information recorded on some medium Layers of software on a computer -BIOS, device drivers - Operating System - Software Applications PROGRAMMERS That’s us! 5 steps a programmer typically follows: 1. Defining the need 2. Designing a flowchart 3. Coding the software 4. Debugging 5. Beta testing THE INTERNET Simple version: Beginning – ARPANET, 1969 – connected 2 computers Today – internet relies on global T3 lines (~45 MB/sec transfer rate) to transmit data requests Smaller “tributary” lines provide data locally Your IP (internet protocol) is unique to your machine – you make a request, it travels along the route to the server where the website is hosted, then the information requested is returned to your IP HOMEWORK Read Chapter 1 in book Book will direct you online to finish chapter Writing Assignment Address the following 3 prompts: 1. Explain the relationship between hardware and software 2. Describe the origins of the internet, how it works, and how it relates to your answer for #1 3. Explain what a programmer does, and give some varied examples 4. Explain yours understanding of computer memory Min – 2 pages (dub space), Max – 3 pages 5. Create a visual diagram of a computer labeling all of the components we took notes on (feel free to include components we didn’t talk about!) add to your writing assignment Your book will be an excellent source for this assignment MEMORY How do computers represent information? Fundamental level – binary! CPU consist of transistors that have 2 states: 0 – low voltage state 1- high voltage state Bit – one binary digit Byte – eight bits 1 byte has 256 different possibilities (2^8 = 256) MEMORY How many combinations will 2 bits have? 00, 01, 10, 11 – 22 = 4 combinations Reading binary: From right to left, each digit is 2^place holder, starting with 0 Ex) 0001 is 2^0 =1, 0010 is 2^1=2 Q: What is 1101 in decimal? NUMBER SYSTEMS Programmers find it useful to be able to quickly convert between decimal and binary 1 way:Example 1 - (Convert Decimal 44 to Binary) subtract the largest power of two, and count that number as a 1 NUMBER SYSTEMS Easier method for large decimal numbers: Division by 2: Take a decimal number, and do long division by your base (in this case, base 2 for binary) Keep track of remainders… divide until the quotient is 1 Read from bottom to top for binary answer Example: 156 to binary Keep remainders to right.. 2)156 0 2)78 0 2)39 1 2)19 1 2)9 1 2)4 0 2)2 0 1 156 = 10011100 NUMBERING SYSTEMS Try to convert the following 00101110101011010010100101011001010010 That is a bit too difficult – instead of trying to read that, programmers typically use a base 16 system, hexadecimal (groups of 4 binary numbers: 2^4 = 16) 0123456789ABCDEF are the 16 hex digits Why not just use the decimal system? It is not a derived from a base 2 system NUMBERING SYSTEMS It is recommended to know these: Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Binary NUMBERING SYSTEMS It is better to know how to convert: Use remainder system to convert from decimal to hex (ex 1243): 1243 / 16 = 77, remainder 11 (B) 77 / 16 = 4, remainder 13 (D) 4 / 16 = 0, remainder 4 1243 = 4DB in hexadecimal (or 04DB) NUMBERING SYSTEMS Convert hex to decimal: try the Hex 11A3 Start from right to left… multiply each by 16^ place value So 3 * 16^0 = 3 A(10) * 16^1 = 160 1 * 16^2 = 256 1 * 16^3 = 4096 Answer: 4096+256+160+3 = 4515 NUMBER SYSTEMS From binary to hex Break binary into chunks of 4: Ex) 101011 = 0010 1011 Convert chunks into decimal 0010 1011 = 2 11 = 2 B From hex to Binary – do the opposite 4A2F = 4 10 2 15 = 0100 1010 0010 1111 NUMBER SYSTEMS Practice: Convert the following to both decimal and hexadecimal: 10000011, 10010011, 10111011 Convert the following Hex’s to both decimal and binary: 34, 5A, CAB HOMEWORK Numbering System Conversion Worksheet Ch 1 Exercises - #1, 2, 5, 11, 12, 13, 14 Create a program that converts: From decimal to binary From decimal to hexadecimal From binary to hexadecimal (the reverse of all of these) You can potentially write one method that takes a base number as a parameter Worksheet due Tuesday; Exercises and program due Wednesday before class ends