You are on page 1of 36

CC3 Computer Programming 2

Procedural vs.
OOP Paradigm

Xeniorita Alondra Bio 2023 February


Week 1-4
Contents

Course Introduction 3

Class Rules 4

Grading System 9

Procedural vs. OOP 10

Review 11

Practice Coding Problem 11

2
Course Introduction

This course explains the fundamental ideas behind the


object-oriented approach to programming. Knowledge of
java helps to create the latest innovations in programming.
Like the successful computer languages that came before,
java is the blend of the best elements of its rich heritage
combined with the innovative concepts required by its
unique environment. This course involves OOP concepts,
java basics, inheritance, polymorphism, interfaces, inner
classes, packages, Exception handling, multithreading,
collection framework, files, JDBC and GUI components.

3
Class Rules
ATTENDANCE
Students are expected to attend all classes, arrive on time, and participate
actively in class discussions and activities. Students with complete attendance
will receive an additional 10% of their major exam grade.
It is not allowed to have 3 consecutive absences. Acceptable reasons for
missing class include illness (with a medical certificate or prescription), the
death of an immediate family member or a family emergency, religious
observance, and school events. If the absence is deemed valid, the student
may make up any missed quizzes, activities, or machine problems on a date
specified by the instructor, with a proper excuse letter.

4
Class Rules
QUIZZES
If the lecturer cannot provide an answer sheet, only yellow paper will be used
for quizzes and activities. Students must use a black ballpen. No erasing is
allowed. If a mistake is made, students may use correction tape or pen, or put
parenthesis around the incorrect portion and add their signature.

RESPECT FOR OTHERS


Students are expected to respect the rights and opinions of others, to engage
in civil discourse, and to refrain from disruptive behavior.

5
Class Rules
TECHNOLOGY USE
Students are expected to use technology appropriately and responsibly in the
classroom and to avoid activities that are distracting or disruptive to others.

ACADEMIC INTEGRITY
Students are expected to adhere to academic standards of honesty and integrity
and to avoid plagiarism, cheating, and other forms of academic misconduct.
Please be aware that a first offense for plagiarism or cheating will result in a
heavy suspension of one week, and a second offense will result in dismissal or
transfer, as outlined in the school's Memorandum of Understanding.

6
Class Rules
LATE WORK
Students are expected to submit work on time. Late submissions (assignments)
will incur a 10% grade deduction per day.

APPROPRIATE BEHAVIOR
Students are expected to maintain appropriate behavior during class, as
directed by the instructor. This includes refraining from eating, drinking, or
using cell phones during class. If a student needs to answer a call, they should
excuse themselves and take the call outside.

7
Class Rules
COMMUNICATION WITH INSTRUCTOR
During the class, students are encouraged to communicate with their
instructor regarding any questions, concerns, or needs related to the course.
Private messages between the student and the instructor are strictly
prohibited. All concerns and questions should be directed to the class
president first, and the president will be the one to communicate with the
instructor.
Note: This rule is in place to promote a transparent and organized
communication process within the class, and to ensure that all students have
equal access to the instructor and to information related to the course.

8
GRADING SYSTEM

ASYNCHRONOUS 30%
WRITTEN QUIZZES, HOMEWORKS

SYNCHRONOUS 30%
EXERCISES, MACHINE PROBLEMS

MAJOR EXAM 40%


WRITTEN EXAM, LAB EXAM

TOTAL 100%

9
Procedural vs. OOP
Procedural
Procedural programming is a type of
programming that follows a structured
approach and is based on the use of
procedures. Procedures, also referred to as
routines, subroutines, or functions, consist of a
set of computational steps to perform. These
procedures can be called at any time during
program execution, including by other
procedures or by the procedure itself.

10
Procedural vs. OOP
OOP
Object-oriented programming (OOP) is a
programming paradigm based on the concept
of objects. Objects in OOP contain both data
(attributes) and code (methods). This
programming model is designed to represent
real-world objects and the interactions
between them. OOP languages can vary, but
the most commonly used are class-based,
where objects are instances of classes that
define their type.

11
Procedural vs. OOP
Procedural OOP
• In procedural programming, the program is • In object-oriented programming, the
divided into small parts called functions. program is divided into small parts called
• Procedural programming follows a top- objects.
down approach. • Object-oriented programming follows a
• There is no access specifier in procedural bottom-up approach.
programming. • Object-oriented programming has access
• Procedural programming does not have any specifiers like private, public, protected, etc.
proper way of hiding data so it is less • Object-oriented programming provides data
secure. hiding so it is more secure.
• Procedural programming uses the concept • Object-oriented programming uses the
of procedure abstraction. concept of data abstraction.

12
Procedural vs. OOP
Procedural OOP
• In procedural programming, overloading is • Overloading is possible in object-oriented
not possible. programming.
• In procedural programming, there is no • In object-oriented programming, the concept
concept of data hiding and inheritance. of data hiding and inheritance is used.
• In procedural programming, the function is • In object-oriented programming, data is more
more important than the data. important than function.
• Procedural programming is based on the • Object-oriented programming is based on the
unreal world. real world.
• Code reusability absent in procedural • Code reusability is present in object-oriented
programming, programming.
• Examples: C, FORTRAN, Pascal, Basic, etc. • Examples: C++, Java, Python, C#, etc.

13
REVIEWING JAVA BASIC SYNTAX

Terminator (semi-colon)

14
REVIEWING JAVA BASIC SYNTAX

Built-in Data Types

15
REVIEWING JAVA BASIC SYNTAX
Declaration and Assignment Statements

16
REVIEWING JAVA BASIC SYNTAX
Booleans

17
REVIEWING JAVA BASIC SYNTAX
Comparison Operators

18
REVIEWING JAVA BASIC SYNTAX
Anatomy of an if statement

*Curly braces are


optional when the loop
body is a single
statement

19
REVIEWING JAVA BASIC SYNTAX
Anatomy of an if-else statement Condition that holds a Boolean value

If block,
executed
if true
else block,
executed
if false

20
REVIEWING JAVA BASIC SYNTAX
Anatomy of an if-else statement Condition that holds a Boolean value

If block,
executed
if true
else block,
executed
if false

21
REVIEWING JAVA BASIC SYNTAX
Anatomy of a While Loop
Initialization

Loop control variable


Condition that holds a
Boolean value

*Curly braces are


optional when the Loop Body -
loop body is a Executed as long as
single statement Update Expression the condition is true

22
REVIEWING JAVA BASIC SYNTAX
Anatomy of a Do-while Loop
Initialization

Loop control variable

*Curly braces are


optional when the Loop Body - Executed as
loop body is a long as the condition is true
single statement Update Expression
Condition that holds a
Boolean value

23
REVIEWING JAVA BASIC SYNTAX
Anatomy of a For Loop Condition
Update Expression
Initialization Loop control variable

*Curly braces
Loop Body -
are optional
when the loop
Executed as long
body is a single as the condition
statement is true

24
REVIEWING JAVA BASIC SYNTAX
Anatomy of an Array New Keyword Base type (Datatype)

Base type (Datatype) Array Identifier


Length / Size

25
REVIEWING JAVA BASIC SYNTAX
Declaring and Populating an Array

Opening Curly Braces


Elements
Base type Identifier
(Datatype)

Square
Bracket Comma (after every
elements) Closing Curly Braces

26
REVIEWING JAVA BASIC SYNTAX
PARAMETER
Anatomy of a Java Method Are input values that are passed
to a method when it is called.
Specified in the method
signature.
Method Signature

METHOD BODY
Contains the code
that executes when
the method is called.
STATIC KEYWORD It is enclosed in curly
Used to define a method as VOID KEYWORD
braces.
a class method or a static Used as a return type for a method
method. Static method that does not return any value and
Access Modifier means that the method can does not have a return statement.
be called directly on the
class, without the need to
create an instance of a class

27
REVIEWING JAVA BASIC SYNTAX
PARAMETER
Anatomy of a Java Method Are input values that are passed
to a method when it is called.
Specified in the method
signature.
Method Signature

METHOD BODY
Contains the code
that executes when
the method is called.
RETURN STATEMENT RETURN TYPE It is enclosed in curly
Is used to specify the value It is specified immediately before braces.
that the method should the method name. The value that a
return to the calling code. method returns must be
Access Modifier compatible with the return type of
the method.

28
CC3L Computer Programming 2

LABORATORY
(Basic Review)

XENIORITA ALONDRA BIO 2023 FEBRUARY


WEEK 1
Laboratory Exercise
Conditional statement (30pts)
Write a program that takes an alphabet as input and prints if it is a vowel or a
consonant.

Looping statement (30pts)


Write a program that calculates the factorial of a given number using any loop.

Arrays (30pts)
Write a program to find the largest and smallest number in an array of integers.
Elements are : 5,6,26,45,14,4,13,12,15,10
Laboratory Exercise
Conditional statement (50pts)
Write a program that takes two integers as input and prints the larger one. If
the first number is the larger one print "Integer1 is larger", if the second
number is larger print "Integer2 is larger", and if both numbers are equal print
"Both numbers are equal."

Looping Statement (50pts)


Write a program that takes an integer as input and prints the multiplication
table of that number from 1 up to 10.
Laboratory Exercise

Conditional statement (30pts)


Write a program that takes an alphabet as input and prints if it is a vowel or a
consonant.

Looping statement (30pts)


Count down from the number specified by the user to zero

Arrays (30pts)
Given an array of integers, find the sum of all elements in the array.
Laboratory Exercise
Conditional statement (30pts)
Write a program that checks the age of the user. If the user enters age 17 and
below display "You are a minor", if the age is 18 and above display "You are in
legal age" and if the age is less than 0 and over 100 display "Invalid age".

Looping statement (30pts)


Write a program that calculates the factorial of a given number using any loop.

Arrays (30pts)
Write a program to find the SUM of all the numbers in an array of integers.
Elements are : 15,52,89,45,45,20,13,12,5,75
CC3L Computer Programming 2

LABORATORY
(EXERCISE 1)

XENIORITA ALONDRA BIO 2023 FEBRUARY


WEEK 1-4
Laboratory Exercise
Write a program that takes 3 array of STRING namely “emails”, “usernames” and “passwords”. The
program will then ask for the email / username and password of the user. Email and username is
not case sensitive while password should be case sensitive. If the user entered a wrong email and
password, display the message “Incorrect email / username and password.” The user should be
able to use either email or username to login the system. If the user successfully entered the
correct details welcome them using their username.
Usernames: alonds, belle14, kimkim, joshpogi, cutiepie
Emails: alondra31@gmail.com, tinker-belle@gmail.com, kimmymalupet@gmail.com,
joshuaPascual@gmail.com, cutekosobra@gmail.com
Passwords: 1234londra, belleMariano, kimmyy15, josh@23, cutecute02
**Use JOptionPane
CC3 - CC3L Computer Programming 2

The End

XENIORITA ALONDRA BIO 2023 FEBRUARY


WEEK 1-4

You might also like