Thursday, June 16, 2016

PHP Programming Activities

PHP Activity 1

Apply all arithmetic operators on the following:

            1. Add 100 and 500.
            2. Subtract the above sum with 200.
            3. Divide the difference by 20
            4. Combine the quotient using concatenation operator with 20.
            5. Multiply the answer to 5.

What would be the answer?

PHP Activity 2

Declare a variable for English, Math, PE, Filipino and Science with the following values: 95, 90, 93, 98, 89. Display the subjects together with their values and average on the web document.

PHP Activity 3

Display heading 1 to heading 6 with the following text and background color.
  • Heading 1 – Today is Monday – Red
  • Heading 2 – Today is Tuesday – Yellow
  • Heading 3 – Today is Wednesday – Blue
  • Heading 4 – Today is Thursday – Green
  • Heading 5 – Today is Friday – Orange
  • Heading 6 – Today is Saturday - White

PHP Activity 4

Declare 2 variables for First Name,  Middle Name and Last Name with the values of “Ruby Mae”, “Jimena” and “Morante”. Display it like this. Morante, Ruby Mae Jimena

PHP Activity 5

Create a program which allows you to convert Bitcoin(BTC) to US Dollar (USD) and Philippine Peso (PHP). Conversion value is 1BTC=$375, $1=P45. Display the conversion values if the value of BTC is 5. 

PHP Activity 6 Conditional Statements

  • Given the following, $grade=87, create a php script to determine whether the grade is a passing grade or not.

PHP Activity 7

78        85        88        90        86        80        82

  • Kindly refer to the figures above for this activity. Create a php script that solves for the average of the above numbers. The output should look like this....
The average of 78, 85, 88, 90, 86, 80 and 82 is 84.14.

PHP Activity 8

  • Create a simple PHP script that allows a user to execute a certain operation based on the possible operator used by a user.
  • Use an if....elseif...else statement. Declare four (4) variables namely the $first for the first number, $second for the second number, $total for the formula and $operator for the operators such as the +, -, / and *.
  • Your sample output should look like this:
The sum of 8 and 9 is 17. or
The product of 8 and 9 is 72.

PHP Activity 9

  • Create a PHP script that allows a user to assign any of the days such as Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday and name it $day.
  • Based on the above declaration, use any conditional statements that will change the background color of a document based on the following:
Monday – Red
Tuesday – Yellow
Wednesday – Blue
Thursday – Green
Friday – Pink
Saturday – Gray
Sunday – Black

PHP Activity 10

  • Using conditional statements, comparison operators and logical operators, create a script that checks whether a certain username and password is valid. If true, it will display a message such as “Successfully Logged In”, otherwise “Invalid username or password”.
Set the username and password as “admin”.

PHP Activity 11

Using any loop statements (do while, while, for loop), display numbers from 1 to 31 inside a dropdown box.

PHP Activity 12

Create a program that increments a loop by 3 until 10 numbers. Sample output: 3,6,9,12,15.

PHP Activity 13

Create a fibonacci series that starts with 0 and 1. The 3rd number will be the sum of the 1st and 2nd number. The sum of the 2nd and 3rd number will be the 4th number and so on and so forth. Display until the 10th number.

ANSWERS will be posted soon.

PHP Programming Activities

No comments:

Post a Comment