0% found this document useful (0 votes)
209 views73 pages

IPRG5111 - Lecture 1S - 2024

The document outlines the objectives and structure of the IPRG5111 Introduction to Programming Logic course, emphasizing foundational programming concepts and methodologies. It covers essential topics such as computer systems, program development cycles, pseudocode, flowcharts, and the importance of logical thinking in programming. Additionally, it provides instructions for accessing the student intranet and resources for further learning.

Uploaded by

shantonjohnson98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
209 views73 pages

IPRG5111 - Lecture 1S - 2024

The document outlines the objectives and structure of the IPRG5111 Introduction to Programming Logic course, emphasizing foundational programming concepts and methodologies. It covers essential topics such as computer systems, program development cycles, pseudocode, flowcharts, and the importance of logical thinking in programming. Additionally, it provides instructions for accessing the student intranet and resources for further learning.

Uploaded by

shantonjohnson98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 73

(http://valenciacollege.edu/asdegrees/information-technology/images/it-computer-programming-analysis.

png)

HMAW – IPRG5111
Introduction to Programming Logic
Lecture 1
Lecturer: Brendan van der Merwe Email times: 8am – 5pm,
Email: bvdmerwe@iie.ac.za Monday to Friday
Contact Details:
Lecturer: Brendan van der Merwe Email times: 8am – 5pm,
Email: bvdmerwe@iie.ac.za Monday to Friday
Objectives
- An overview of IPRG5111

In your first Lecture, you will learn about:


• Computer systems
• Simple program logic
• The steps involved in the program development cycle
• Pseudocode statements and flowchart symbols Lecture 1
• Using a sentinel value to end a program
• Programming and user environments
• The evolution of programming models
Link to Ppt
https://drive.google.com/drive/folders/
1NIPHFzDS-APfMP4h9TGx2vXZxk2t2L4n?
usp=sharing
Module Outline
- Module Outline

Introduction - An overview of IPRG5111


In this module you will learn the various programming concepts and
approaches critical to a good understanding of programming methodology.

Logical thinking is arguably the most important skill for a software engineer.

In conjunction with creativity, logical design facilitates the abstraction of the


real world to the digital world.

The purpose of this module is to provide you with foundational and practical
knowledge required for effective programming, enabling you to derive intuitive
and innovative solutions to a greater variety of real-world problems, following
a hands-on approach.
- Module Outline
- Module Outline
- Accessing the Student Intranet

Steps to access the 2024 Student Intranet:


• Go the varsity college website here: https://www.varsitycollege.co.za/
• Click current students
• Click My VC student intranet
• Fill in your email and password
- Module Outline

This Module on a LMS

This is an online space, designed to support and maximise your


learning in an active manner. Its main purpose is to guide and pace
you through the module. In addition to the information provided in
this document, you will find the following when you access the LMS:

• A list of prescribed material;


• Critical questions to guide you through the module’s objectives;
• A variety of additional online resources (articles, videos, audio,
interactive graphics, etc.) in each learning unit that will further help
to explain theoretical concepts;
• Collaborative and individual activities with time-on-task estimates
to assist you in managing your time around these;
- Module Outline

Units = Chapters in the book


Unit Chapters

1 1, 2, 3 and 4

2 5

3 6

4 7

5 8
- PAS Doc

Please note: I cannot accept late submission/resubmissions without the permission of the
Student Hub.
Please come to campus as soon as possible so that a CRO can assist you to apply for a
resubmission concession via the IIE Student Hub.
Chapter 1
Chapter 1: Programming and Problem Solving
Understanding Computer Systems

– Combination of all the components required to process and store


data using a computer.
Understanding Computer Systems
• Hardware
– Physical equipment associated with a computer

• Software
– Computer instructions that tells the hardware what to do
– Programs
• Instructions written by programmers
- Programming
• Writing software instructions
Computer Hardware
Internal memory

RAM – Random Access Memory


(volatile), ROM – Read Only
Memory (non-volatile), CMOS,
Cache

Input Processor Output device


device
Mouse Screen/Monitor
System unit – CPU
Keyboard Printer
(brain),
Virtual Keyboard Speakers
motherboard,
Trackball Headphones
expansion slots,
Scanner
power supply,
Touchpad
network card,
Touchscreen
internal modem,
Stylus
WiFi card.
Games Controller
Joystick
Webcam Storage devices
Digital Camera
Finger print reader Hard drives, External Hard
Iris Scan drives, Solid State drives,
Memory card USB’s, Memory cards, Blu-
reader ray, DVD’s, CD’s, online
Microphone storage
Software

System Software: Application Software:


Software that controls the Software to accomplish
basic computer operations certain specific tasks
such as printing and
storage
Two Basic Types: Word Processing,
Type: An operating System Types of spreadsheets, databases,
web browsing, accounting
Brands:
Microsoft Windows Software systems.
Linux
Brands:
Apple operating System (Lion)
MS Word 2010, MS Excel 2010,
Ubuntu
Internet Explorer 9, Windows
Media Player
Phone OS: Google Android (Used by Samsung)
Windows Phone 7, iOS5 (Apple – iphone)
What is a Program?
Understanding Computer Systems
• Computer hardware and software accomplish three
major operations
– Input
• Data items such as text, numbers, images, and sound
– Processing
• Calculations and comparisons performed by the central processing
unit (CPU)
– Output
• Resulting information that is sent to a printer,
a monitor, or storage devices after processing
Understanding Computer Systems
• Programming language
– Used to write computer instructions called program code
– Writing instructions is called coding the program
– Examples
• Visual Basic, C#, C++, or Java
A Simple Computer Program
Set of instructions telling the
computer what to do

This code works out Simple


Interest

SOURCE CODE : CLOSED and OPEN


• Programming language - Java

Syntax

Vocabulary of Programming Language (Words used to make up statements )

• Syntax
– Rules governing word usage and punctuation
– Mistakes in a language’s usage are syntax errors
• Programming languages
Understanding Computer Systems
• Compiler or interpreter
– Translates source code into machine language (binary language)
statements called object code
– Checks for syntax errors

• Program executes or runs


– Input will be accepted, some processing will occur, and results will be
output

– Netbeans example
Machine Language / Machine Code
Assembly and machine language are closer to the hardware
and require more understanding of the underlying
architecture.
Java = High Level (Human Readable)

Assembly = Low Level

Binary = Machine Language


Compiler / interpreter
Actual Java code you have typed

Compiler converts to bytecode

Interpreter converts to Machine Language

Operating system executes the code


Understanding Simple Program Logic
• Programs with syntax errors cannot execute
• Logical errors
– Errors in program logic produce incorrect output

• Logic of the computer program


– Sequence of specific instructions in specific order
Activity:
Activity:
Understanding the Program
Development Cycle
• Program development cycle
– Understand the problem
– Plan the logic
– Code the program
– Use software (a compiler or interpreter) to translate the
program into machine language
– Test the program
– Put the program into production
– Maintain the program
Understanding the Program
Development Cycle
Understanding the Problem
• One of the most difficult aspects of programming

• Users or end users


– People for whom a program is written

• Documentation
– All supporting paperwork for a program
Planning the Logic
• Plan the steps of the program and what they include
• An algorithm is the sequence of steps or rules you
follow to solve a problem
• Most common planning tools
– Flowcharts
– Pseudocode

• Desk-checking
– Walking through a program’s logic on paper before you
actually write the program
Coding the Program
• Hundreds of programming languages available
– Choose based on features
– Similar in their basic capabilities

• Coding is easier than the planning step

• Experienced programmers can successfully combine


logic planning and program coding in one step
Using Software to Translate the
Program into Machine Language
• Translator program
– Compiler or interpreter
– Changes the programmer’s English-like high-level
programming language into the low-level machine
language

• Syntax error
– Misuse of a language’s grammar rules
– Programmer corrects listed syntax errors
– Might need to recompile the code several times
Using Software to Translate the Program
into Machine Language
Testing the Program
• Logical error
– Results when a syntactically correct statement, but the
wrong one for the current context, is used
• Test
– Execute the program with some sample data to see
whether the results are logically correct
• Debugging is the process of finding and correcting
program errors
• Programs should be tested with many sets of data
Putting the Program into Production
• Process depends on program’s purpose
– May take several months
• Conversion
– The entire set of actions an organization must take to
switch over to using a new program or set of programs
Maintaining the Program
• Maintenance
– Making changes after the program is put into production

• Common first programming job


– Maintaining previously written programs

• Make changes to existing programs


– Repeat the development cycle
Using Pseudocode Statements
and Flowchart Symbols
• Pseudocode
– English-like representation of the logical steps it takes to
solve a problem

• Flowchart
– Pictorial representation of the logical steps it takes to solve
a problem
Pseudocode VS Flowcharts
• Pseudocode - English-like representation of the • Flowchart - Pictorial representation of the logical
logical steps it takes to solve a problem steps it takes to solve a problem

start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop

- Pseudocode representation of a number-doubling problem


Pseudocode Standards
• Programs begin with the word start and end with the
word stop; these two words are always aligned
• Whenever a module name is used, it is followed by a
set of parentheses ()
• Modules begin with the module name and end with
return. The module name and return are always
aligned
• Each program statement performs one action—for
example, input, processing, or output
Pseudocode Standards
• Program statements are indented a few spaces more
than the word start or the module name
• Each program statement appears on a single line if
possible. When this is not possible, continuation lines
are indented
• Program statements begin with lowercase letters
• No punctuation is used to end statements
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
Drawing Flowcharts
• Create a flowchart
– Draw geometric shapes that contain the individual
statements
– Connect shapes with arrows
• Input symbol
– Indicates input operation
– Parallelogram
• Processing symbol
– Contains processing statements
such as arithmetic
– Rectangle
Drawing Flowcharts
• Output symbol
– Represents output statements
– Parallelogram
• Flowlines
– Arrows that connect steps
• Terminal symbols
– Start/stop symbols
– Shaped like a racetrack
– Also called lozenges
Drawing Flowcharts
Exercise 1 (I do)
1. Draw a flowchart and write pseudocode to represent the logic of a
program that allows the user to enter a value. The program divides
the value by 2 and outputs the result.
Exercise 1 (I do)

https://www.programiz.com/java-programming/online-compiler/
Exercise 2 (We do)
2. Draw a flowchart and write pseudocode to represent the logic of a
program that allows the user to enter two values. The program outputs
the product of the two values.
Exercise 3 (You do)
3. Draw a flowchart or write pseudocode to represent the logic of a program
that allows the user to enter a value for hours worked in a day. The program
calculates the hours worked in a five-day week and the hours worked in a 252-
day work year. The program outputs all the results.
Repeating Instructions

• Program in Figure 1-7 only works for one number. What if we wanted to
input more numbers? Say 10 000 numbers?
• Not feasible to run the program over and over 10,000 times
• Not feasible to add 10,000 lines of code to a program
Repeating Instructions
Repeating Instructions
• Create a loop (repetition of a series of steps) instead

Avoid an infinite loop


(repeating flow of
logic that never ends)
Using a Sentinel Value to End
a Program
• Making a decision
– Testing a value
– Decision symbol
• Diamond shape
• Dummy value
– Data-entry value that the user will never need
– Sentinel value
• eof (“end of file”)
– Marker at the end of a file that automatically acts as a
sentinel
Using a Sentinel Value to End
a Program (continued -1)
Understanding Programming
and User Environments
• Understanding Programming Environments
– Text Editor is used to create simple text files
– Integrated development environment (IDE) provides an
editor, compiler, and other programming tools
• Microsoft Visual Studio IDE
• Understanding User Environments
– Command line is a location on your computer screen at
which you type text entries to communicate with the
computer’s operating system
– A graphical user interface, or GUI (pronounced gooey),
allows users to interact with a program in a graphical
environment
Understanding Programming
Environments
Understanding Programming Environments
Understanding User Environments
Understanding User Environments
Understanding the Evolution
of Programming Models
• People have been writing modern computer
programs since the 1940s
• Newer programming languages
– Look much more like natural language
– Are easier to use
– Create self-contained modules or program segments that
can be pieced together in a variety of ways (Netbeans Bug
Example)
Understanding the Evolution
of Programming Models
• Major models or paradigms used by programmers
– Procedural programming
• Focuses on the procedures that programmers
create
– Object-oriented programming
• Focuses on objects, or “things,” and describes
their features (or attributes) and their
behaviors
Example of reusing a Class:
import it.*;
import java.awt.*;

public class MakeRect


{
public static void main (String[]args)
{
Gogga bug = new Gogga();

bug.move(); Gogga flea = new Gogga();


bug.move(); flea.setTrailWidth(10);
bug.move(); flea.setColor(Color.blue);
bug.move(); flea.setPosition(3,9);
bug.move(); flea.move();
bug.turnLeft(); flea.move();
bug.move(); flea.move();
bug.move(); flea.move();
bug.turnLeft(); flea.move();
bug.move(); flea.turnLeft();
bug.move(); flea.move();
bug.move(); flea.move();
bug.move(); flea.turnLeft();
bug.move(); flea.move();
bug.turnLeft(); flea.move();
bug.move(); flea.move();
bug.move(); flea.move();
bug.turnLeft(); flea.move();
flea.turnLeft();
flea.move();
flea.move();
flea.turnLeft();
}
Kench, D. (2015). Exploring IT : Java Programming.Funworks
Summary
• Hardware and software accomplish input, processing,
and output
• Logic must be developed correctly
• Logical errors are much more difficult to locate than
syntax errors
• Use flowcharts and pseudocode to plan the logic
• Avoid infinite loops by testing for a sentinel value
• Use a text editor or an IDE to enter your program
statements
Exercise (You do)
&

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy