SlideShare a Scribd company logo
1 of 23
CS0007: Introduction to Computer
Programming
Introduction to Computers and
Programming
Programming – Why?
 Computers are used for many different purposes
in many different situations.
 But, how can they be so versatile?
 Answer: They can be programmed
 The ability for a computer to be programmed
allows it to do whatever their programs tell them
what to do.
 A program is a set of instructions that tell a
computer what to do.
 A computer cannot do anything unless it has a
program to tell it what to do.
 In this class, we will focus on writing these
programs.
Programming – What?
 Programs are used to operate the components of a
computer, solve problems or satisfy a want/need.
 How long will it take me to get home if I drive x miles per
hour?
 I want to be able to tell my friends what I am doing right
now.
 Computer Programming is both an Art and a Science
 Every aspect of a program must be carefully designed
 As an art, programming takes creativity and problem
solving.
 There is often no one correct way to solve a problem.
 As a science, there are formal and proven methods to
go about creating a programming.
 In this course, you will learn both the art and science
of programming.
Hardware and Software
 Programs can also be called software.
 Software refers to the computer programs that a
computer uses to complete a task.
 Hardware refers to the physical components that a
computer is made of.
 A computer is not one device, but a system of devices
working in tandem.
 Each device plays a part.
 Major components:
 Central Processing Unit
 Main Memory
 Secondary Storage Devices
 Input Devices
 Output Devices
Central Processing Unit (CPU)
 The CPU is the heart and brain of the computer.
 The CPU continuously does the following things:
1. Fetch an instruction
2. Follow the instruction
3. Produce some resulting data
 The CPU has two parts:
 Control Unit
 Coordinates the computer’s operations
 Determines where to get the next instruction
 Regulates the other major components of the computer
 Arithmetic and Logic Unit (ALU)
 Designed to perform mathematical operations
Main Memory
 Main memory holds information that the CPU needs to
access quickly.
 Namely, the instructions to be executed.
 When a program is running, some or all of its instructions
are in main memory.
 Memory is divided into sections called bytes that hold
equal amount of data.
 Each section is made up of 8 bits.
 A Bit is the most basic unit of information a computer can hold.
It is a switch that is either on (1) or off (0)
 Each byte is assigned and can be accessed by its
address.
 A Memory Address is a unique identifying number associated
with a byte in memory.
 Main memory typically is volatile.
 Volatile Memory – is memory that when it loses power, the
contents are erased.
Secondary Storage
 Secondary Storage is memory that can hold data for a long
period of time.
 Programs are usually stored in secondary storage and loaded
into main memory as needed.
 This forms a hierarchy typically called the memory hierarchy.
 Common forms of secondary storage:
 Hard Drive
 Disk Drive
 Solid State Drive
 Removable Storage
 Floppy Disk
 CD-ROM
 USB Drives
 Other files can be stored in secondary storage:
 Documents
 Pictures
 Whatever else you save on your computer
Input Devices
 Input is any data the computer collects from the
outside world.
 An Input Device is anything that collects data and
sends it to the computer.
 Common Input Devices:
 Keyboard
 Mouse
 Scanner
 Digital Camera
 Disk Drive
 USB Drive
Output Devices
 Output is any data the computer sends to the
outside world.
 An Output Device formats data and presents it to
the outside world.
 Common Output Devices:
 Monitor
 Printer
 Disk Drive
 USB Drive
Software
 Software refers to the programs that run on a
computer.
 Two main categories (for this class):
 Operating System (OS)
 A set of programs that manages a computer’s hardware
devices and controls their processes.
 Most modern operating systems are capable of running
multiple programs at once.
 UNIX, Linux, Mac OS X, and Windows are examples
 Application Software
 Programs that make the computer useful for the user
 Solve specific problems or supply a service
 Word processors, spreadsheets, databases, etc.
 This is what we will be developing in this class.
Program Development Cycle
 Many programmers follow a sequence of Steps to
create their programs.
1. Analyze – Define the Problem
 Make sure that you understand what the program
should do. What should the user be able to
enter? How? How does the program come up
with an answer? What does the program output?
How?
 User – a person who uses a computer program.
 End User – the user that the program was made for.
2. Design – Plan a Solution for the Problem
 Develop a PRECISE sequence of steps to solve
the problem
 An algorithm is a precise sequence of steps to solve a
problem.
Develop an Algorithm
 Imagine you want a program that tells a user how
many stamps they need in order to mail a certain
number of pages.
 You need one stamp for every 5 pages
 6 pages = 2 stamps
 12 pages = 3 stamps
 …
 Write an algorithm (the steps needed) to solve
this problem
Program Development Cycle –
Design (Continued)
 Typically a program follows three general steps
1. Input
2. Processing (Formulas)
3. Output
Develop an Algorithm, 2nd
Attempt
 OK, with this knowledge, try writing the algorithm
again
Program Development Cycle –
Design (Continued)
 Are those three steps enough?
 What about if the user enters “Banana” instead of a number of
sheets?
 The program does not know how to find the number of stamps
required to mail “Banana” number of sheets
 In order for the program to run without crashing, our algorithm
must make sure that the user inputs some valid data.
 There are two main ways of doing this:
1. Prevention – Making sure that the user is not physically able to enter in
invalid data.
2. Validation – Allowing the user to enter invalid data, but checking it to
make sure it is valid before processing.
 So, there are really 4 general steps most programs follow:
1. Input
1. Read Input
2. Validate Input
2. Process
3. Output
Develop an Algorithm, 3rd Attempt
 OK, now with THAT information, try developing
the algorithm
 One good algorithm developed could look like
this:
1. Request the number of sheets of paper from the
user; call it Sheets (Input/Read)
2. Make sure Sheets is a positive whole number
(Input/Validation)
3. Divide Sheets by 5 (Processing)
4. Round the result from step 3 up to the highest
whole number; call it Stamps (Processing)
5. Reply with the number Stamps (Output)
Programming Tools
 Flowcharts – A chart that consists of symbols
connected by arrows. Within each symbol is a
phrase presenting the activity at that step. The
shape of the symbol indicates the type of
operation that is to occur.
 Hierarchy Charts – A chart that shows the overall
program structure. These charts describe what
each part, or module, does and how they are
related. These modules intentionally omit details
of how they work.
 Pseudocode – an abbreviated plain English
version of actual computer code. Kind of a mix
between English and code. THERE IS NO
OFFICIAL SYNTAX TO PSEUDOCODE.
Flow Charts
 Flow Line - indicates the flow of logic
 Terminal – indicates the start or end of a task
 Input/Output – used for input or output
operations. What is to be input or output should
be in the figure.
Flow Charts
 Processing - used to show a processing step.
The instructions are displayed in the figure.
 Decision – used to show when a decision needs
to be made. Lines for yes and no come out of it.
The question is displayed in the figure.
 Connector – Used to join flow lines.
Stamps Flowchart
Yes
No
Start
Read
Sheets
Is sheets a
positive
whole
number?
Display
Error
Message
Set Stamps
= Sheets/5
Round Stamps to
nearest whole
number
Display
Stamps
End
Hierarchy Chart
Postage
Stamp
Program
Calculate
Stamps
Display
Stamps
Input
Read
Sheets
Validate
Sheets
Set Stamps
= Sheets/5
Round Stamps to
the next whole
number
Program Development Cycle
3. Write the Code – Implement a solution
 The instructions in a programming language
collectively called code.
 Your code should be a translation of your
algorithm developed into the programming
language.
 In this class we use Java, but there are many other
programming languages: C, C++, C#, Ruby, Python,
Visual Basic, etc.
 This is the major focus of this course, but note
that you need to be able to think algorithmically in
order to do this.
 Meaning, you need to be able to logically solve the
problem in order to write a program for it.
Program Development Cycle
4. Testing and Debugging – Locate and remove any errors
in the program
 Testing is the process of finding errors in a program
 Debugging is the process of removing errors in a program.
 An error in a program is called a bug.
 We will talk more specifically about the kinds of errors that
can occur in a program once we start programming.
5. Complete All Documentation – Organize the material that
describes the program.
 Documentation is any material whose purpose is to allow
another person or programmer to use or understand the
program
 Two kinds of documentation:
1. External Documentation – Material outside of the code files that
describe the program.
2. Internal Documentation – Lines inside of a code file that do nothing
except describe details of the program. In Java, these are called
comments.

More Related Content

Similar to Introduction.pptx

Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)TejaswiB4
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer ProgrammingProf. Erwin Globio
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmmshoaib15
 
Computer Programming Computer Programming
Computer Programming Computer ProgrammingComputer Programming Computer Programming
Computer Programming Computer Programmingarifhasan88
 
Program logic and design
Program logic and designProgram logic and design
Program logic and designChaffey College
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptxgaafergoda
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5Alok Jain
 
lecture1422486950.pdf
lecture1422486950.pdflecture1422486950.pdf
lecture1422486950.pdftomsmith160
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesFellowBuddy.com
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptxshoaibkhan716300
 

Similar to Introduction.pptx (20)

Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)
 
Introduction to Programming.docx
Introduction to Programming.docxIntroduction to Programming.docx
Introduction to Programming.docx
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
 
01CHAP_1.PPT
01CHAP_1.PPT01CHAP_1.PPT
01CHAP_1.PPT
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
PPS Unit-1.pdf
PPS Unit-1.pdfPPS Unit-1.pdf
PPS Unit-1.pdf
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Computer Programming Computer Programming
Computer Programming Computer ProgrammingComputer Programming Computer Programming
Computer Programming Computer Programming
 
UNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptxUNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptx
 
01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx
 
Program logic and design
Program logic and designProgram logic and design
Program logic and design
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5
 
PROBLEM SOLVING
PROBLEM SOLVINGPROBLEM SOLVING
PROBLEM SOLVING
 
CC-112-Lec.1.ppsx
CC-112-Lec.1.ppsxCC-112-Lec.1.ppsx
CC-112-Lec.1.ppsx
 
CISY 105 Chapter 1
CISY 105 Chapter 1CISY 105 Chapter 1
CISY 105 Chapter 1
 
lecture1422486950.pdf
lecture1422486950.pdflecture1422486950.pdf
lecture1422486950.pdf
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
 
C with lab
C with labC with lab
C with lab
 
Programming_Lecture_1.pptx
Programming_Lecture_1.pptxProgramming_Lecture_1.pptx
Programming_Lecture_1.pptx
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Introduction.pptx

  • 1. CS0007: Introduction to Computer Programming Introduction to Computers and Programming
  • 2. Programming – Why?  Computers are used for many different purposes in many different situations.  But, how can they be so versatile?  Answer: They can be programmed  The ability for a computer to be programmed allows it to do whatever their programs tell them what to do.  A program is a set of instructions that tell a computer what to do.  A computer cannot do anything unless it has a program to tell it what to do.  In this class, we will focus on writing these programs.
  • 3. Programming – What?  Programs are used to operate the components of a computer, solve problems or satisfy a want/need.  How long will it take me to get home if I drive x miles per hour?  I want to be able to tell my friends what I am doing right now.  Computer Programming is both an Art and a Science  Every aspect of a program must be carefully designed  As an art, programming takes creativity and problem solving.  There is often no one correct way to solve a problem.  As a science, there are formal and proven methods to go about creating a programming.  In this course, you will learn both the art and science of programming.
  • 4. Hardware and Software  Programs can also be called software.  Software refers to the computer programs that a computer uses to complete a task.  Hardware refers to the physical components that a computer is made of.  A computer is not one device, but a system of devices working in tandem.  Each device plays a part.  Major components:  Central Processing Unit  Main Memory  Secondary Storage Devices  Input Devices  Output Devices
  • 5. Central Processing Unit (CPU)  The CPU is the heart and brain of the computer.  The CPU continuously does the following things: 1. Fetch an instruction 2. Follow the instruction 3. Produce some resulting data  The CPU has two parts:  Control Unit  Coordinates the computer’s operations  Determines where to get the next instruction  Regulates the other major components of the computer  Arithmetic and Logic Unit (ALU)  Designed to perform mathematical operations
  • 6. Main Memory  Main memory holds information that the CPU needs to access quickly.  Namely, the instructions to be executed.  When a program is running, some or all of its instructions are in main memory.  Memory is divided into sections called bytes that hold equal amount of data.  Each section is made up of 8 bits.  A Bit is the most basic unit of information a computer can hold. It is a switch that is either on (1) or off (0)  Each byte is assigned and can be accessed by its address.  A Memory Address is a unique identifying number associated with a byte in memory.  Main memory typically is volatile.  Volatile Memory – is memory that when it loses power, the contents are erased.
  • 7. Secondary Storage  Secondary Storage is memory that can hold data for a long period of time.  Programs are usually stored in secondary storage and loaded into main memory as needed.  This forms a hierarchy typically called the memory hierarchy.  Common forms of secondary storage:  Hard Drive  Disk Drive  Solid State Drive  Removable Storage  Floppy Disk  CD-ROM  USB Drives  Other files can be stored in secondary storage:  Documents  Pictures  Whatever else you save on your computer
  • 8. Input Devices  Input is any data the computer collects from the outside world.  An Input Device is anything that collects data and sends it to the computer.  Common Input Devices:  Keyboard  Mouse  Scanner  Digital Camera  Disk Drive  USB Drive
  • 9. Output Devices  Output is any data the computer sends to the outside world.  An Output Device formats data and presents it to the outside world.  Common Output Devices:  Monitor  Printer  Disk Drive  USB Drive
  • 10. Software  Software refers to the programs that run on a computer.  Two main categories (for this class):  Operating System (OS)  A set of programs that manages a computer’s hardware devices and controls their processes.  Most modern operating systems are capable of running multiple programs at once.  UNIX, Linux, Mac OS X, and Windows are examples  Application Software  Programs that make the computer useful for the user  Solve specific problems or supply a service  Word processors, spreadsheets, databases, etc.  This is what we will be developing in this class.
  • 11. Program Development Cycle  Many programmers follow a sequence of Steps to create their programs. 1. Analyze – Define the Problem  Make sure that you understand what the program should do. What should the user be able to enter? How? How does the program come up with an answer? What does the program output? How?  User – a person who uses a computer program.  End User – the user that the program was made for. 2. Design – Plan a Solution for the Problem  Develop a PRECISE sequence of steps to solve the problem  An algorithm is a precise sequence of steps to solve a problem.
  • 12. Develop an Algorithm  Imagine you want a program that tells a user how many stamps they need in order to mail a certain number of pages.  You need one stamp for every 5 pages  6 pages = 2 stamps  12 pages = 3 stamps  …  Write an algorithm (the steps needed) to solve this problem
  • 13. Program Development Cycle – Design (Continued)  Typically a program follows three general steps 1. Input 2. Processing (Formulas) 3. Output
  • 14. Develop an Algorithm, 2nd Attempt  OK, with this knowledge, try writing the algorithm again
  • 15. Program Development Cycle – Design (Continued)  Are those three steps enough?  What about if the user enters “Banana” instead of a number of sheets?  The program does not know how to find the number of stamps required to mail “Banana” number of sheets  In order for the program to run without crashing, our algorithm must make sure that the user inputs some valid data.  There are two main ways of doing this: 1. Prevention – Making sure that the user is not physically able to enter in invalid data. 2. Validation – Allowing the user to enter invalid data, but checking it to make sure it is valid before processing.  So, there are really 4 general steps most programs follow: 1. Input 1. Read Input 2. Validate Input 2. Process 3. Output
  • 16. Develop an Algorithm, 3rd Attempt  OK, now with THAT information, try developing the algorithm  One good algorithm developed could look like this: 1. Request the number of sheets of paper from the user; call it Sheets (Input/Read) 2. Make sure Sheets is a positive whole number (Input/Validation) 3. Divide Sheets by 5 (Processing) 4. Round the result from step 3 up to the highest whole number; call it Stamps (Processing) 5. Reply with the number Stamps (Output)
  • 17. Programming Tools  Flowcharts – A chart that consists of symbols connected by arrows. Within each symbol is a phrase presenting the activity at that step. The shape of the symbol indicates the type of operation that is to occur.  Hierarchy Charts – A chart that shows the overall program structure. These charts describe what each part, or module, does and how they are related. These modules intentionally omit details of how they work.  Pseudocode – an abbreviated plain English version of actual computer code. Kind of a mix between English and code. THERE IS NO OFFICIAL SYNTAX TO PSEUDOCODE.
  • 18. Flow Charts  Flow Line - indicates the flow of logic  Terminal – indicates the start or end of a task  Input/Output – used for input or output operations. What is to be input or output should be in the figure.
  • 19. Flow Charts  Processing - used to show a processing step. The instructions are displayed in the figure.  Decision – used to show when a decision needs to be made. Lines for yes and no come out of it. The question is displayed in the figure.  Connector – Used to join flow lines.
  • 20. Stamps Flowchart Yes No Start Read Sheets Is sheets a positive whole number? Display Error Message Set Stamps = Sheets/5 Round Stamps to nearest whole number Display Stamps End
  • 22. Program Development Cycle 3. Write the Code – Implement a solution  The instructions in a programming language collectively called code.  Your code should be a translation of your algorithm developed into the programming language.  In this class we use Java, but there are many other programming languages: C, C++, C#, Ruby, Python, Visual Basic, etc.  This is the major focus of this course, but note that you need to be able to think algorithmically in order to do this.  Meaning, you need to be able to logically solve the problem in order to write a program for it.
  • 23. Program Development Cycle 4. Testing and Debugging – Locate and remove any errors in the program  Testing is the process of finding errors in a program  Debugging is the process of removing errors in a program.  An error in a program is called a bug.  We will talk more specifically about the kinds of errors that can occur in a program once we start programming. 5. Complete All Documentation – Organize the material that describes the program.  Documentation is any material whose purpose is to allow another person or programmer to use or understand the program  Two kinds of documentation: 1. External Documentation – Material outside of the code files that describe the program. 2. Internal Documentation – Lines inside of a code file that do nothing except describe details of the program. In Java, these are called comments.