IPRG5111 - Lecture 1S - 2024
IPRG5111 - Lecture 1S - 2024
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
Logical thinking is arguably the most important skill for a software engineer.
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
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
• Software
– Computer instructions that tells the hardware what to do
– Programs
• Instructions written by programmers
- Programming
• Writing software instructions
Computer Hardware
Internal memory
Syntax
• 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
– 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)
• 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
• 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
• 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
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