0% found this document useful (0 votes)
3 views27 pages

Introduction to Programming Concepts

This document provides an introduction to programming, focusing on core concepts such as variables, loops, and functions, and highlights the role of programming in problem-solving. It specifically discusses Java as a high-level, object-oriented programming language, its applications, and the tools needed for development. Additionally, it covers algorithm development, flowcharting, and pseudocode as methods for translating logic into executable code.

Uploaded by

sergzcagulang
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)
3 views27 pages

Introduction to Programming Concepts

This document provides an introduction to programming, focusing on core concepts such as variables, loops, and functions, and highlights the role of programming in problem-solving. It specifically discusses Java as a high-level, object-oriented programming language, its applications, and the tools needed for development. Additionally, it covers algorithm development, flowcharting, and pseudocode as methods for translating logic into executable code.

Uploaded by

sergzcagulang
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

Module 1: Programming Languages

Introduction to Programming
What is Programming?
Programming - is the process of creating instructions that a
computer can execute to perform tasks.

The first 5 core concepts you need to learn are:


• Variables
• If Statements
• Arrays
• Loops
• Functions

Role of Programming in Problem-Solving


1. Breaks problems into steps so solutions are easier to find.
2. Turns logic into code that a computer can execute.
3. Automates repetitive tasks to save time and reduce errors.
4. Helps test and fix errors for correct solutions.
5. Supports decision-making by processing data efficiently.
Compiler - A compiler translates code from a high-level programming
language into machine code before the program runs.

Interpreter - interpreter translates code written in a high-level programming


language into machine code line-by-line as the code runs.
Overview of Java Programming
Java Programming Language
High-level & Object-Oriented - Java is designed to be easy to read, write, and maintain, using objects to
model real-world concepts.

History & Development - Developed by Sun Microsystems in 1995 as a versatile language for multiple
platforms.

Java Compiler & Execution Java - is both a compiled and interpreted programming language. Because
it employs both compilation and interpretation to run code, it is known as a "compiler-interpreter
language.“
Applications of Java:
• Desktop Applications: Building software that runs on personal computers.
• Web Applications: Developing dynamic websites and online services.
• Android Apps: Powering most mobile applications on Android devices.
• Enterprise Systems: Supporting large-scale business applications and backend systems.

Java Programming Environment


JDK (Java Development Kit)
• Provides tools to write, compile, and run Java programs
• Includes Java compiler (javac) and Java runtime (java)
IDE (Integrated Development Environment)
• Software that makes coding easier
• Features: code editor, debugging, project management
• Examples: IntelliJ IDEA, Eclipse, NetBeans, VScode
Why Java?
• Very popular general-purpose
language
• It’s almost entirely object-oriented
• It has a vast library of predefined
objects and operations
• Widely used for many applications
(desktop, web, mobile).
• Strong community support and lots
Java Program Structure
Programming with the Problem
[Link] the Problem
• Know exactly what needs to be solved.
• Example: “I want a program that adds two numbers.” or “Check if
a number is even or odd”
[Link] / Breaking down the problem
• Split the problem into smaller steps.
• Example steps: “I want a program that adds two numbers”
1. Ask the user for two numbers
2. Add the numbers
3. Show the result
[Link] / Translating Logic into Java Code
• Convert your steps into Java instructions.
[Link] Style – Compile, Run, Debug, Output
• Turn your code into a working program
• Test it, fix errors, and see the output
Flowcharting and Algorithm
Development
Importance of Algorithms
Writing a logical, step-by-step method to solve a problem is called the algorithm. In other words,
an algorithm is a procedure for solving problems. This is the first step in the process of solving a
mathematical or computer problem.
Flowcharting
A flowchart is the graphical or pictorial representation of an algorithm with the help of different
symbols, shapes, and arrows to demonstrate a process or a program.
Algorithms with Selection and Repetition
Algorithms follow a sequence of steps, but not all code must run sequentially. We can create
more complex algorithms by branching (choosing different paths) or looping (repeating code).

Algorithms are built from three core structures: sequence (steps in order), selection
(decisions/branching), and repetition (loops). Any solvable problem can be expressed using just
these three.
Sequence
Doing steps one after another in order.

Morning Routine 1
• Wake up.
• Brush your teeth.
• Take a shower.
• Get dressed.
• Eat breakfast.
• Pack your bag.
• Leave for school or work.
Selection
Selection is the process of making a choice based on a true or false
decision.
Morning routine 2:
1. Wake up.
2. Snooze for 5 more minutes.
3. Check your phone and the weather
4. If there is a text from your friend, answer it.
5. Brush teeth and shower.
6. If it’s cold, wear a sweater.
7. Check if you have homework due. If so,
pack it in your bag.
8. Put on your sunglasses if it’s sunny.
9. Leave for school or work.
Repetition
Repetition is when a process repeats itself until a desired outcome is
reached.
Morning routine 3:
1. Wake up.
2. Snooze for 5 more minutes. Keep waking up
and snoozing for the next 15 minutes
3. If there is a text from your friend, answer it.
Do this for all of your texts.
4. Brush teeth and shower.
5. If it’s cold, wear a sweater.
6. Check if you have homework due. If so,
pack it in your bag.
7. Repeat packing items until your bag is
ready.
8. Leave for school or work.
Translating algorithms into
pseudocode
Pseudocode - describes the distinct steps of an algorithm in a
way that anyone with basic programming skills can understand.
The Main Constructs of Pseudocode:
How to Write Pseudocode
1. Always capitalize the initial word (often one of the main six
constructs).
2. Make only one statement per line.
3. Indent to show hierarchy, improve readability and show nested
constructs.
4. Always end multi-line sections using any of the END keywords
(ENDIF, ENDWHILE, etc.).
5. Keep your statements programming language independent.
6. Use the naming domain of the problem, not that of the
implementation. For instance: “Append the last name to the first
name” instead of “name = first+last.”
7. Keep it simple, concise and readable.
Samples of Pseudocode Example 2 – Find the Largest of Three
Numbers
Example 1 – Adding Two Numbers
START
START READ number1
READ number1 READ number2
READ number2 READ number3
sum = number1 + number2 IF number1 >= number2 AND number1
>= number3 THEN
DISPLAY "The sum is ", sum DISPLAY "The largest number is ",
number1
STOP ELSE IF number2 >= number1 AND
number2 >= number3 THEN
DISPLAY "The largest number is ",
number2
ELSE
DISPLAY "The largest number is ",
number3
ENDIF

STOP
Samples of Pseudocode
Example 3 – User Input: Adding Two
Numbers

START
ASK USER to enter first number
READ number1

ASK USER to enter second number


READ number2

sum = number1 + number2

DISPLAY "The sum is ", sum


STOP
Problem Statement
Write a program that asks the user to enter the current temperature in Celsius. The
program should display a message basedSTART
on the temperature:

• Above 30°C: “It’s hot outside” ASK USER to enter the temperature in Celsius
• 21°C to 30°C: “The weather is warm” READ temperature
• 11°C to 20°C: “It’s cool”
• 0°C to 10°C: “It’s cold” IF temperature > 30 THEN
• Below 0°C: “Freezing weather” DISPLAY "It’s hot outside"
ELSE IF temperature >= 21 AND temperature <=
30 THEN
DISPLAY "The weather is warm"
ELSE IF temperature >= 11 AND temperature <=
20 THEN
DISPLAY "It’s cool"
ELSE IF temperature >= 0 AND temperature <=
10 THEN
DISPLAY "It’s cold"
ELSE
DISPLAY "Freezing weather"
ENDIF

STOP
Quiz Activity 1: Write Pseudocode
1. Problem Statement: Write a pseudocode that checks if a person can enter a
movie theater.
If the person’s age is 18 or older, print “You can enter.” Otherwise, print “You
are not allowed.”

2. Problem Statement: Write a pseudocode that prints the numbers 1 to 5 using a


loop.

3. Problem Statement: Write a pseudocode that asks the user for a number. If the
number is greater than 100, print “Number is large.” Otherwise, print
“Number is small or equal to 100.”

4. Problem Statement: Write a pseudocode that asks the user for their score and
prints the corresponding grade:
• 90–100 → “A”
• 80–89 → “B”
• 70–79 → “C”
• Below 70 → “Failed”

5. Problem Statement: Write a pseudocode that asks the user to enter a username

You might also like