MTWRF 9:45-11:15 AM Sitterson 011 1 O ffj ce hours: MW 1-2 PM If - - PowerPoint PPT Presentation

mtwrf 9 45 11 15 am sitterson 011
SMART_READER_LITE
LIVE PREVIEW

MTWRF 9:45-11:15 AM Sitterson 011 1 O ffj ce hours: MW 1-2 PM If - - PowerPoint PPT Presentation

Darrell Bethea May 10, 2011 MTWRF 9:45-11:15 AM Sitterson 011 1 O ffj ce hours: MW 1-2 PM If you still cannot make it to either o ffj ce hour, email me to set up an appointment if you need help with an assignment. Hardware and


slide-1
SLIDE 1

Darrell Bethea May 10, 2011

MTWRF 9:45-11:15 AM Sitterson 011

1

slide-2
SLIDE 2

 Offjce hours: MW 1-2 PM  If you still cannot make it to either offjce

hour, email me to set up an appointment if you need help with an assignment.

slide-3
SLIDE 3

 Hardware and Memory  Programs and Compiling  Your first program

slide-4
SLIDE 4

 Need to know basics of a computer

  • If you want to cook, you should know basic

ingredients and understand how food is prepared.

 Understand what your program is doing  Talk intelligently about computers

5

slide-5
SLIDE 5

 Hardware - physical machine

  • CPU, Memory

 Software - programs that give instructions to

the computer

  • Windows XP, Google Chrome, Games, Eclipse

6

slide-6
SLIDE 6

 CPU (Central Processing Unit) - the “Brain”

  • GHz

 Number of billions of instructions per second  I.e, how fast the computer is

  • Dual Core - multiple processing units per CPU

7

slide-7
SLIDE 7

 Holds data for the computer  How much the “Brain” can remember  Main Memory

  • Memory computer uses for intermediate

calculations (program you are running)

  • Disappears when you shut down your computer

 Secondary Memory

  • Disk drives, CDs, Flash drives
  • Exists until you delete it

8

slide-8
SLIDE 8

 Your main memory  2 gigabytes of RAM

  • (Meter - unit of distance)
  • Bytes - unit of data
  • Kilobyte = 1 thousand bytes
  • Megabyte = 1 million bytes
  • Gigabyte = 1 billion bytes

9

slide-9
SLIDE 9

 Smallest addressable unit of memory  Both main memory and auxiliary memory are

measured in bits

 1 byte = 8 bits  Bit = 0 or 1 (on or ofg)  Language of the computer is bits  0 0 1 1 1 0 1 0 - 1 byte of 8 bits

10

slide-10
SLIDE 10

 Set of instructions for a CPU to follow  Also known as software.  You will be writing programs

  • We will look at one soon

 Hard for humans to write bits directly

11

slide-11
SLIDE 11

Your Program Compiler Machine Language (Bits) High-level language (human readable) Low-level language (computer readable)

12

slide-12
SLIDE 12

 What are the two kinds of memory in a

computer?

 What is software?  What is the difgerence between a machine-

language program and a high-level language program?

13

slide-13
SLIDE 13

import java.util.*;

public class FirstProgram { public static void main(String[] args) { System.out.println("Hello out there."); System.out.println("I will add two number for you."); System.out.println("Enter two whole numbers on a line:"); int n1, n2; Scanner keyboard = new Scanner(System.in); n1 = keyboard.nextInt(); n2 = keyboard.nextInt(); System.out.println("The sum of those two numbers is"); System.out.println(n1 + n2); } }

14

slide-14
SLIDE 14

import java.util.*;

  • Package = Library of classes
  • Java.util is a package
  • Different libraries give different information
  • Physics Library = Newtonian Physics
  • Music Library = your iTunes collection
  • java.util. = Allows you to read data from keyboard

15

slide-15
SLIDE 15

public class FirstProgram { public static void main(String[] args) {

  • Begin a program named FirstProgram
  • Program names should make sense
  • Another name for this program could be
  • AddTwoNumbers
  • You should always capitalize the first letter of

each word in your program name

16

Begin the Program

slide-16
SLIDE 16

System.out.println("Hello out there."); System.out.println("I will add two numbers for you."); System.out.println("Enter two whole numbers on a line:");

  • Write what is in quotes to screen

17

slide-17
SLIDE 17

 Class - Category of Objects

  • E.g., Stapler

 Object - A specific member of that category

  • E.g., My red Swingline

 Method - Actions performed by objects

  • E.g., Staple pages, load staples, fix jam, etc.

18

slide-18
SLIDE 18

myRedSwingLine.fixJam(); ramses.eatGrass(); System.out.println(“Hi”);

Object Method Invoke Method

19

slide-19
SLIDE 19

int n1, n2;

 Variable - store piece of data  n1 - store integer  n2 - store integer

20

slide-20
SLIDE 20

Scanner keyboard = new Scanner(System.in); Create object (keyboard) of Scanner class Stapler myRedSwingLine = new Stapler();

Class Object Not always System.in

21

slide-21
SLIDE 21

n1 = keyboard.nextInt(); Read an integer from the keyboard and store it in n1

Object Method Invoke/Call

22

slide-22
SLIDE 22

System.out.println("The sum of those two numbers is"): System.out.println(n1 + n2);

Add n1 and n2 Print the sum to the screen

23

slide-23
SLIDE 23

import java.util.*;

public class FirstProgram { public static void main(String[] args) { System.out.println("Hello out there."); System.out.println("I will add two number for you."); System.out.println("Enter two whole numbers on a line:"); int n1, n2; Scanner keyboard = new Scanner(System.in); n1 = keyboard.nextInt(); n2 = keyboard.nextInt(); System.out.println("The sum of those two numbers is"); System.out.println(n1 + n2); } }

24

slide-24
SLIDE 24

Hello out there. I will add two numbers for you. Enter two whole numbers on a line: 12 30 The sum of those two numbers is 42

Input by user

slide-25
SLIDE 25

 Eclipse  Your first java program  Download and Install Eclipse before lab (see

webpage)

 Go through the Eclipse Tutorial on your own  Get the textbook!  Read 1.1-1.3

Before Tomorrow