OOP Week 1
OOP Week 1
Programming
Object-Oriented Programming
chapters
01 Introduction 04 Programming
Language
03 Elements of a
Computer System 06 Algorithm
Introduction
course policies
Expectations from this class:
• Attendance is a MUST
(student will be dropped from the class if their absences goes over 20% of total class hours)
1956
Invention of the transistors
that resulted in smaller,
faster more reliable, and
more energy efficient
Elements of a
Computer System
Hardware
physical components of
a computer system, they
are the tangible parts
such as the
motherboard, processor,
memory, etc…
central processing unit and
main memory
Output:
processing a java program
Editor
Compiler Error
No Error
Library Bytecode
Loader
Interpreter
Algorithm
programming with the problem-analysis-
coding-execution cycle
Analysis
Algorithm Design
Coding
Compiler Error
Library Bytecode
Loader
Interpreter Error
Results
Let’s practice!
Design an Algorithm to play a number guessing game:
The objective is to randomly generate an integer greater than or equal to 0 and less
than 100. Then, prompt the player (user) to guess the number. If the player guesses
the number correctly, output an appropriate message. Otherwise, check whether the
guessed number is less than the random number. If the guessed number is less than
the random number, output the message “Your guess is lower than the number. Guess
Again!”; otherwise output the message “Your guess is higher than the number. Guess
Again!”. The player is prompted to guess the random number until the player enters
the correct number.
Let’s Practice!
Things we need:
random number
guess number
suppose;
random number = num
guess number = guess
Let’s Practice!
pseudocode:
Every salesperson has a base salary. The salesperson also receives a bonus at the end
of each month, based on the following criteria: If the salesperson has been with the
store for five years or less, the bonus is $10 for each year that he or she has worked
there. If the sales person has been with the store for more than five years, the bonus is
$20 for each year that he or she has worked there. The salesperson can earn an
additional bonus as follows: If the total sales made by the salesperson for the month
are greater than $5000 but less than $10000, he or she receives a 3% commission on
the sale. If the total soles made by the sales person for the month are at least $10000,
he or she receives a 6% commission on the sale.
Try This!
To calculate the salesperson’s paycheck, you need to know:
the base salary
the number of service years
total sales made for the month
suppose;
base salary = baseSalary
the number of service years = noOfServiceYears
total sales for the month = totalSales
bonus = bonus
additional bonus = addBonus
THANK
S! Does anyone have any
questions?
[email protected]
+63 968 275 6798