Lecture 1 2024
Lecture 1 2024
Introduction to programming
• Repeat the following steps while the balance is less than P20,000 (double the
original)
Answer: 4 years:
0 10,000
1 12,000
2 14,400
3 17,280
4 20,736
From Algorithm to Programs
Pseudocode
• Pseudocode is an informal language that helps you
develop algorithms without having to worry about
the strict details of Java language syntax.
• Particularly useful for developing algorithms that
will be converted to structured portions of Java
programs.
• Similar to everyday English.
• Helps you “think out” a program before attempting
to write it in a programming language, such as
Java.
Pseudocode Cont….
• You can type pseudocode conveniently, using any
text-editor program.
• Carefully prepared pseudocode can easily be
converted to a corresponding Java program.
• Pseudocode normally describes only statements
representing the actions that occur
• After you convert a program from pseudocode to
Java and the program is run on a computer.
• e.g., input, output or calculations.
Self Check 1.22
Suppose your cell phone carrier charges you P29.95 for up to 300
minutes of calls, and P0.45 for each additional minute, plus 12.5
percent taxes and fees. Give an algorithm to compute the monthly
charge for a given number of minutes.
Answer:
Is the number of minutes at most 300?
A. If so, the answer is P29.95 + (12.5/100 *29.95) = P33.70
B. If not,
1.Compute the difference: (number of minutes) – 300.