PSA2 Technical - PHP Operators and Control Structure
PSA2 Technical - PHP Operators and Control Structure
PRE-SUMMATIVE ASSESSMENT
2
PHP OPERATORS AND CONTROL STRUCTURE
Section:
Professor:
LABORATORY ACTIVITY
2. Using conditional statement create a grade ranking program, integrated with HTML and CSS.
Example
Grade = 92 Ranking: A-
Use the equivalents below
A: 93-100
A-: 90-92
B+: 87-89
B: 83-86
B-: 80-82
C+: 77-79
C: 73-76
C-: 70-72
D+: 67-69
D: 63-66
D-: 60-62
F: Below 60
Sample Output
Grade: Picture
Rank: A
95
3. Using Looping Statements write a program which will give you all of the potential combinations
of a two-digit decimal combination, printed in a comma delimited format:
Sample output :
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99,
Output:
1. What are the different Arithmetic operators used in the lab activity? describe each
In this lab activity, I mostly used multiplication and division. I used them both in the first activity
when I’m converting the lengths into different metrics.
2. Can you apply formula in webpages? Give an example
Yes, you can apply formulas in webpages. In the first activity, I applied a formula to convert the
lengths into different metric systems.
3. What are the different conditional statements? Describe each
if statement - executes some code if one condition is true
if...else statement - executes some code if a condition is true and another code if that condition is
false
if...elseif...else statement - executes different codes for more than two conditions
switch statement - selects one of many blocks of code to be executed
4. Can you create a condition inside of a condition?
Yes, it is called nesting. You can do it in loops or in conditional statements.
5. Do you think these conditional statements is important in the program? Then why?
Yes, because it lets the program be dynamic
6. What are the different looping statements in PHP? Describe each
while - loops through a block of code as long as the specified condition is true
do while - loops through a block of code once, and then repeats the loop as long as the specified
condition is true
for - loops through a block of code a specified number of times
for each - loops through a block of code for each element in an array
7. What is the importance of looping?
Loops allow them to shorten what could be hundreds of lines of code to just a few. This allows
them to write the code once and repeat it as many times as needed, making it more likely for the
program to run as expected.