hardware bits and bytes Java Introduction hardware bits and bytes Java
What we will do in this class Understand how to control a computer with a programming language. Learn (and practice) strategies and techniques for programming. Learn and use Java.
Hardware and Software Hardware is the machine CPU, monitor, keyboard, speakers, disks, chips Software is the programs that make the machine do things.
Memory the CPU is the chip that does the computation RAM (processor memory) is the storage for programs and data that are in active use.
Input and output devices Input devices: keyboard, mouse, touch part of touch screen, microphone,camera, hard drive, instruments like thermometers... Output devices: monitor, speakers, printer, hard drive, controllers ...
Analogue vs Digital Analogue - old record players, film cameras, speech Digital - audio CDs, digital cameras, written words
Binary Numbers How high can you count on your fingers? (Assuming 10 fingers)
How to count to 1023 on your fingers, (and why you will snicker at the number 4) 128 256 4 8 64 2 512 1 32 16 credit: http://www.hannahsnailsdsm.webs.com/
Bits and Bytes How many bits it takes to represent the days of the week the months of a year one million different colors A byte is 8 bits. How many bytes would it take...
Storing Information 9278 9279 9280 9281 9282 9283 9284 9285 9286 Each memory cell stores a set number of bits (usually 8 bits, or one byte) 10011010 Large values are stored in consecutive memory locations Copyright © 2012 Pearson Education, Inc.
From program to execution Each CPU has its own machine language. Typically, a compiler converts a program to machine language. Different versions of the compiler for different machines.
From program to execution: Java A Java compiler converts the program to bytecode - the same for all machines. An interpreter translates the bytecode to machine code and executes it.
Java Introduced in 1995 by Sun Goal: programs that could be run on any computer, run over the web. Includes its own graphics, including GUIs. Object oriented language.
Program Example: Facts.java credit: Lewis and Loftus
Comments
Comments // A single line comment /* This comment can be on many lines */
class class body Class header
main method main method body main method header
printing System.out.println semicolon ends each statement a string literal between the quotes
concatenation + to put two strings together, concatenation
concatenation a number gets converted to a string for concatenation
skipping a line no parameter, just prints a line
oops! Go from start to end, one command at a time. output: We present the following facts foryour extracurricular edification: Letters in the Hawaiian alphabet: 12 Dialing Code for Antarctica: 672 Year in which Leonardo da Vinci invented the parachute: 1515 Speed of ketchup: 40 km per year Go from start to end, one command at a time.
Escape Sequences Special characters as part of a string: \n newline \t tab \" quote \' single quote \\ backslash