 Hardware: Electronic Devices  Software: Instructions and Computer Programs
 Input : Keyboard, Mouse  System unit:  Random Access Memory (RAM)  Central Processing Unit (CPU)  Output: Monitor, Printer  Secondary Storage: Disk Drive
 Instructions for the hardware.  Actions to be performed  A set of instructions is called a program.  Driving force behind the computer  Without a program –What is a computer? ▪ Collection of Useless Hardware  2 purposes:  Tell the computer what to do  Tell other people what we want the computer to do.
 The central processing unit (CPU)  The “brain” of a computer  Retrieves instructions from memory and executes them.
 Stores data and program instructions for CPU to execute  A program and its data must be brought to memory before they can be executed  Stores intermediate and final results of processing.  Volatile: Contents are erased when computer is turned off or reset.
 A memory unit is an ordered sequence of bytes, each holds eight bits.  A byte is the minimum storage unit.  No two data can share or split the same byte.  Devices are Hard Drives, CDs/DVDs, Flash Drives, etc.  Non-Volatile or Permanent Storage  Programs and data are permanently stored on storage devices and are moved to memory when the computer actually uses them.
 Core operational units of digital devices have two stable states,  which are referred to as zero and one by convention  Combinations of different units with different states are represented with the binary number system  0 and 1.  A single digit (0 or 1) is called a bit, represents either of binary states.
 Binary Language  Data and instructions are encoded as binary numbers - a series of bits  one or more bytes made up of zeros and ones
 Encoding and decoding of data into binary is performed automatically by the system based on the encoding scheme  Encoding schemes  Numeric Data: Encoded as binary numbers  Non-Numeric Data: Encoded as binary numbers using representative code ▪ ASCII – 1 byte per character (character means symbol) ▪ Unicode – 2 bytes per character
 Base 10, ten digits (0-9)  The position (place) values are integral powers of 10:  100(ones), 101(tens), 102(hundreds), 103(thousands)…  (372)10 = 3 × 102 + 7 × 101 + 2 × 100 = 3 × 100 + 7 × 10 + 2 × 1 = 300 + 70 + 2  n decimal digits - 10n unique values
 Base 2, two digits (0-1)  The position (place) values are integral powers of 2:  20(1), 21(2), 22(4), 23(8), 24(16), 25(32), 26(64)…  (101)2 = 1 × 22 + 0 × 21 + 1 × 20 = 1 × 4 + 0 × 2 + 1 × 1 = 4 + 0 + 1 = (5)10  n binary digits - 2n unique values
 Computers can not use human languages,  Programming in the binary language of computers is a very difficult, tedious process  Therefore, most programs are written using a programming language  are converted to the binary language used by the computer
 Three major categories of programming languages:  Machine Language  Assembly Language  High level Language
 Natural language of a particular computer  Primitive instructions built into every computer  The instructions are in the form of binary code  Any other types of languages must be translated down to this level
 English-likeAbbreviations used for operations (Load R1, R8)  Assembly languages were developed to make programming easier  The computer cannot understand assembly language  - a program called assembler is used to convert assembly language programs into machine code
 English-like and easy to learn and program  Common mathematical notation  area = radius * radius * 3.1415;  Java, C, C++, FORTRAN,VISUAL BASIC, PASCAL
A program written in a high-level language is called a source program (or source code). Since a computer cannot understand a source program. Program called a compiler is used to translate the source program into a machine language program called an object program.The object program is often then linked with other supporting library code before the object can be executed on the machine. 19 Compiler Source File Object File Linker Excutable File
 Programming – the creation of an ordered set of instructions to solve a problem with a computer.  Only about 100 instructions that the computer understands - Different programs will just use these instructions in different orders and combinations.  The most valuable part of learning to program is learning how to think about arranging the sequence of instructions to solve the problem or carry out the task
 Sequential Processing  A List of Instructions  Conditional Execution  if / else  Repetition  Looping / Repeating  Stepwise Refinement /Top-Down Design  BreakingThings into Smaller Pieces  Calling Methods / Functions / Procedures / Subroutines  Calling a segment of code located elsewhere  Reuse of previously coded code segment
 Procedural  Defining set of steps to transform inputs into outputs  Translating steps into code  Constructed as a set of procedures  Each procedure is a set of instructions  Object-Oriented  Defining/utilizing objects to represent real-world entities that work together to solve problem  Basic O-O Programming Components ▪ Class ▪ Object/Instance ▪ Properties ▪ Methods
 The process of defining a problem, searching for relevant information and resources about the problem, and of discovering, designing, and evaluating the solutions for further opportunities. Includes:  Finding an Answer to a Question  Figuring out how to Perform aTask  Figure out how to MakeThingsWork  Not enough to know a particular programming language… Must be able to problem solve…
 Read the Problem: Understand the description of problem or scenario, identifying the knowns and unkowns  Decide how to go about solving the problem: Determine what steps need to be taken to reach the solution  Solve the Problem: Write the solution  Test the Answer: Make sure the answer is correct
 In general, when we solve a computing problem we are taking some inputs, processing (performing some actions on) the inputs, and then outputting the solution or results.  This is the classic view of computer programming – computation as calculation  Polya’s steps (UDIE) can be very effective when applied to solving computing problems
 What is the Problem to be solved?What is the unknown?What is the condition?What is the data?What is needed to solve the problem? What actions need to take place?  Identify the inputs and outputs  Identify the processes needed to produce the outputs from the given inputs  Draw a figure. Introduce suitable notation.  Isolate Principle parts of the problem.
 Find connections between the knowns and unknowns.  Simplify: Break the problem into smaller sub- problems  Design a solution  Make a plan or list of actions to implement the solution  Algorithm / Flowchart / Psuedocode
 Algorithm  A FINITE set of clear, executable steps that will eventually terminate to produce the desired outcome  Logical design used to solve problems – usually a list of actions required to perform task  Pseudocode  Written like program code but more “English Like” and doesn’t have to conform to language syntax  Flowchart  Diagram that visually represents the steps to be performed to arrive at solution.
 Implement in a Programming Language  Carry out the plan checking the preliminary results at each step.  Code A LittleTest A lot
 Run the Code  Check results repeatedly and thoroughly  Use numerous test cases or data sets  Use highly varied test case, including expected as well as and unexpected cases  Look for new solutions  Is there a better, easier, or more efficient solution  Can other problems be solved using these techniques?
35  Tools are used to convert algorithms into computer programs:  Flowchart - Graphically depicts the logical steps to carry out a task and shows how the steps relate to each other.  Pseudocode - Uses English-like phrases with some programming terms to outline the program.
36  How many stamps do you use when mailing a letter?  One rule of thumb is to use one stamp for every five sheets of paper or fraction thereof.
37 1. Request the number of sheets of paper; call it Sheets. (input) 2. Divide Sheets by 5. (processing) 3. Round the quotient up to the next highest whole number; call it Stamps. (processing) 4. Reply with the number Stamps. (output)
38  Graphically depict the logical steps to carry out a task and show how the steps relate to each other.
39
40
41
42  Uses English-like phrases to outline the task.
43 Determine the proper number of stamps for a letter Read Sheets (input) Set the number of stamps to Sheets / 5 (processing) Round the number of stamps up to the next whole number (processing) Display the number of stamps (output)
44  Used in problem solving – take a large problem and break it into smaller problems solving the small ones first  Breaks a problem down into modules
45  Sequence – follow instructions from one line to the next without skipping over any lines  Decision - if the answer to a question is “Yes” then one group of instructions is executed. If the answer is “No,” then another is executed  Looping – a series of instructions are executed over and over
46
47
48
49  Problem: Given a street number of a one-way street in NewYork City, decide the direction of the street, either eastbound or westbound  Discussion: in NewYork City even numbered streets are Eastbound, odd numbered streets areWestbound
50
51 Program: Determine the direction of a numbered NYC street Get street If street is evenThen Display Eastbound Else Display Westbound End If
52  Problem: Calculate and report the grade-point average for a class  Discussion: The average grade equals the sum of all grades divided by the number of students Output: Average grade Input: Student grades Processing: Find the sum of the grades; count the number of students; calculate average
53
54 Program: Determine the average grade of a class Initialize Counter and Sum to 0 DoWhile there are more data Get the next Grade Add the Grade to the Sum Increment the Counter Loop ComputerAverage = Sum / Counter Display Average
 U - Read the Problem Statement  Identify the inputs, outputs, and processes  D - Decide how to Solve the Problem  Create an Algorithm / Flowchart / Psuedocode  I - Program the Code  Implement in Programming Language  E -Test the Solution  Run the Code using numerous, varied test cases
Using Polya’s first 2 steps, understand and devise a solution to the following problem:  Determine the week’s earnings for an employee from the hourly pay rate and hours worked for the week. Report the gross earnings (including overtime earnings) for the week.  Definitions:  Overtime hours = hours over 40  Overtime pay rate = 1.5 * reg pay rate
Using Polya’s first 2 steps, understand and devise a solution to the following problem: Determine the week’s earnings for an employee from the hourly pay rate, total hours for the week and tax rate. Report the number of reg hours, overtime hours, gross reg earnings, gross overtime earnings, tax witheld, and total net earnings for the week. Definitions:  Overtime hours = hours over 40  Overtime pay rate = 1.5 * reg pay rate
 Write an algorithm to serve as how-to instructions for some relatively simple task or activity. You choose the task, should be 10-20 steps in length. Assume you are writing instructions for someone who has never performed task before.

Computer Programming Computer Programming

  • 2.
     Hardware: ElectronicDevices  Software: Instructions and Computer Programs
  • 3.
     Input :Keyboard, Mouse  System unit:  Random Access Memory (RAM)  Central Processing Unit (CPU)  Output: Monitor, Printer  Secondary Storage: Disk Drive
  • 4.
     Instructions forthe hardware.  Actions to be performed  A set of instructions is called a program.  Driving force behind the computer  Without a program –What is a computer? ▪ Collection of Useless Hardware  2 purposes:  Tell the computer what to do  Tell other people what we want the computer to do.
  • 5.
     The centralprocessing unit (CPU)  The “brain” of a computer  Retrieves instructions from memory and executes them.
  • 6.
     Stores dataand program instructions for CPU to execute  A program and its data must be brought to memory before they can be executed  Stores intermediate and final results of processing.  Volatile: Contents are erased when computer is turned off or reset.
  • 7.
     A memoryunit is an ordered sequence of bytes, each holds eight bits.  A byte is the minimum storage unit.  No two data can share or split the same byte.  Devices are Hard Drives, CDs/DVDs, Flash Drives, etc.  Non-Volatile or Permanent Storage  Programs and data are permanently stored on storage devices and are moved to memory when the computer actually uses them.
  • 8.
     Core operationalunits of digital devices have two stable states,  which are referred to as zero and one by convention  Combinations of different units with different states are represented with the binary number system  0 and 1.  A single digit (0 or 1) is called a bit, represents either of binary states.
  • 9.
     Binary Language Data and instructions are encoded as binary numbers - a series of bits  one or more bytes made up of zeros and ones
  • 10.
     Encoding anddecoding of data into binary is performed automatically by the system based on the encoding scheme  Encoding schemes  Numeric Data: Encoded as binary numbers  Non-Numeric Data: Encoded as binary numbers using representative code ▪ ASCII – 1 byte per character (character means symbol) ▪ Unicode – 2 bytes per character
  • 11.
     Base 10,ten digits (0-9)  The position (place) values are integral powers of 10:  100(ones), 101(tens), 102(hundreds), 103(thousands)…  (372)10 = 3 × 102 + 7 × 101 + 2 × 100 = 3 × 100 + 7 × 10 + 2 × 1 = 300 + 70 + 2  n decimal digits - 10n unique values
  • 12.
     Base 2,two digits (0-1)  The position (place) values are integral powers of 2:  20(1), 21(2), 22(4), 23(8), 24(16), 25(32), 26(64)…  (101)2 = 1 × 22 + 0 × 21 + 1 × 20 = 1 × 4 + 0 × 2 + 1 × 1 = 4 + 0 + 1 = (5)10  n binary digits - 2n unique values
  • 14.
     Computers cannot use human languages,  Programming in the binary language of computers is a very difficult, tedious process  Therefore, most programs are written using a programming language  are converted to the binary language used by the computer
  • 15.
     Three majorcategories of programming languages:  Machine Language  Assembly Language  High level Language
  • 16.
     Natural languageof a particular computer  Primitive instructions built into every computer  The instructions are in the form of binary code  Any other types of languages must be translated down to this level
  • 17.
     English-likeAbbreviations usedfor operations (Load R1, R8)  Assembly languages were developed to make programming easier  The computer cannot understand assembly language  - a program called assembler is used to convert assembly language programs into machine code
  • 18.
     English-like andeasy to learn and program  Common mathematical notation  area = radius * radius * 3.1415;  Java, C, C++, FORTRAN,VISUAL BASIC, PASCAL
  • 19.
    A program writtenin a high-level language is called a source program (or source code). Since a computer cannot understand a source program. Program called a compiler is used to translate the source program into a machine language program called an object program.The object program is often then linked with other supporting library code before the object can be executed on the machine. 19 Compiler Source File Object File Linker Excutable File
  • 20.
     Programming –the creation of an ordered set of instructions to solve a problem with a computer.  Only about 100 instructions that the computer understands - Different programs will just use these instructions in different orders and combinations.  The most valuable part of learning to program is learning how to think about arranging the sequence of instructions to solve the problem or carry out the task
  • 21.
     Sequential Processing A List of Instructions  Conditional Execution  if / else  Repetition  Looping / Repeating  Stepwise Refinement /Top-Down Design  BreakingThings into Smaller Pieces  Calling Methods / Functions / Procedures / Subroutines  Calling a segment of code located elsewhere  Reuse of previously coded code segment
  • 22.
     Procedural  Definingset of steps to transform inputs into outputs  Translating steps into code  Constructed as a set of procedures  Each procedure is a set of instructions  Object-Oriented  Defining/utilizing objects to represent real-world entities that work together to solve problem  Basic O-O Programming Components ▪ Class ▪ Object/Instance ▪ Properties ▪ Methods
  • 23.
     The processof defining a problem, searching for relevant information and resources about the problem, and of discovering, designing, and evaluating the solutions for further opportunities. Includes:  Finding an Answer to a Question  Figuring out how to Perform aTask  Figure out how to MakeThingsWork  Not enough to know a particular programming language… Must be able to problem solve…
  • 24.
     Read theProblem: Understand the description of problem or scenario, identifying the knowns and unkowns  Decide how to go about solving the problem: Determine what steps need to be taken to reach the solution  Solve the Problem: Write the solution  Test the Answer: Make sure the answer is correct
  • 25.
     In general,when we solve a computing problem we are taking some inputs, processing (performing some actions on) the inputs, and then outputting the solution or results.  This is the classic view of computer programming – computation as calculation  Polya’s steps (UDIE) can be very effective when applied to solving computing problems
  • 27.
     What isthe Problem to be solved?What is the unknown?What is the condition?What is the data?What is needed to solve the problem? What actions need to take place?  Identify the inputs and outputs  Identify the processes needed to produce the outputs from the given inputs  Draw a figure. Introduce suitable notation.  Isolate Principle parts of the problem.
  • 28.
     Find connectionsbetween the knowns and unknowns.  Simplify: Break the problem into smaller sub- problems  Design a solution  Make a plan or list of actions to implement the solution  Algorithm / Flowchart / Psuedocode
  • 29.
     Algorithm  AFINITE set of clear, executable steps that will eventually terminate to produce the desired outcome  Logical design used to solve problems – usually a list of actions required to perform task  Pseudocode  Written like program code but more “English Like” and doesn’t have to conform to language syntax  Flowchart  Diagram that visually represents the steps to be performed to arrive at solution.
  • 30.
     Implement ina Programming Language  Carry out the plan checking the preliminary results at each step.  Code A LittleTest A lot
  • 31.
     Run theCode  Check results repeatedly and thoroughly  Use numerous test cases or data sets  Use highly varied test case, including expected as well as and unexpected cases  Look for new solutions  Is there a better, easier, or more efficient solution  Can other problems be solved using these techniques?
  • 32.
    35  Tools areused to convert algorithms into computer programs:  Flowchart - Graphically depicts the logical steps to carry out a task and shows how the steps relate to each other.  Pseudocode - Uses English-like phrases with some programming terms to outline the program.
  • 33.
    36  How manystamps do you use when mailing a letter?  One rule of thumb is to use one stamp for every five sheets of paper or fraction thereof.
  • 34.
    37 1. Request thenumber of sheets of paper; call it Sheets. (input) 2. Divide Sheets by 5. (processing) 3. Round the quotient up to the next highest whole number; call it Stamps. (processing) 4. Reply with the number Stamps. (output)
  • 35.
    38  Graphically depictthe logical steps to carry out a task and show how the steps relate to each other.
  • 36.
  • 37.
  • 38.
  • 39.
    42  Uses English-likephrases to outline the task.
  • 40.
    43 Determine the propernumber of stamps for a letter Read Sheets (input) Set the number of stamps to Sheets / 5 (processing) Round the number of stamps up to the next whole number (processing) Display the number of stamps (output)
  • 41.
    44  Used inproblem solving – take a large problem and break it into smaller problems solving the small ones first  Breaks a problem down into modules
  • 42.
    45  Sequence –follow instructions from one line to the next without skipping over any lines  Decision - if the answer to a question is “Yes” then one group of instructions is executed. If the answer is “No,” then another is executed  Looping – a series of instructions are executed over and over
  • 43.
  • 44.
  • 45.
  • 46.
    49  Problem: Givena street number of a one-way street in NewYork City, decide the direction of the street, either eastbound or westbound  Discussion: in NewYork City even numbered streets are Eastbound, odd numbered streets areWestbound
  • 47.
  • 48.
    51 Program: Determine thedirection of a numbered NYC street Get street If street is evenThen Display Eastbound Else Display Westbound End If
  • 49.
    52  Problem: Calculateand report the grade-point average for a class  Discussion: The average grade equals the sum of all grades divided by the number of students Output: Average grade Input: Student grades Processing: Find the sum of the grades; count the number of students; calculate average
  • 50.
  • 51.
    54 Program: Determine theaverage grade of a class Initialize Counter and Sum to 0 DoWhile there are more data Get the next Grade Add the Grade to the Sum Increment the Counter Loop ComputerAverage = Sum / Counter Display Average
  • 52.
     U -Read the Problem Statement  Identify the inputs, outputs, and processes  D - Decide how to Solve the Problem  Create an Algorithm / Flowchart / Psuedocode  I - Program the Code  Implement in Programming Language  E -Test the Solution  Run the Code using numerous, varied test cases
  • 53.
    Using Polya’s first2 steps, understand and devise a solution to the following problem:  Determine the week’s earnings for an employee from the hourly pay rate and hours worked for the week. Report the gross earnings (including overtime earnings) for the week.  Definitions:  Overtime hours = hours over 40  Overtime pay rate = 1.5 * reg pay rate
  • 54.
    Using Polya’s first2 steps, understand and devise a solution to the following problem: Determine the week’s earnings for an employee from the hourly pay rate, total hours for the week and tax rate. Report the number of reg hours, overtime hours, gross reg earnings, gross overtime earnings, tax witheld, and total net earnings for the week. Definitions:  Overtime hours = hours over 40  Overtime pay rate = 1.5 * reg pay rate
  • 55.
     Write analgorithm to serve as how-to instructions for some relatively simple task or activity. You choose the task, should be 10-20 steps in length. Assume you are writing instructions for someone who has never performed task before.