PHP Decision Making

PHP decision making statements allow us to make a decision based on some conditions.

PHP decision making is frequently used to perform tasks based on some calculations. Therefore, it is good to practice on these and understand how PHP If-Else, and switch statements works.

Here, you will find Assignments & Exercises related to PHP Variables. These exercises list contains exercise description and instructions. You need to write a program as per instructions. Then you can match it with our solution.

All PHP Decision Making and conditional statement based exercises are available in the form of PHP program description, instruction and their solution. These PHP programs can also be given as an assignment for PHP students.

Write a program to calculate Electricity bill in PHP

Description:

You need to write a PHP program to calculate electricity bill using if-else conditions.

Conditions:

  • For first 50 units – Rs. 3.50/unit
  • For next 100 units – Rs. 4.00/unit
  • For next 100 units – Rs. 5.20/unit
  • For units above 250 – Rs. 6.50/unit
  • You can use conditional statements.

Click to View Solution/Program

Output:

Output of the Electicity Bill Program

calculate-electricity-bill-in-php


Write a simple calculator program in PHP using switch case

Description:

You need to write a simple calculator program in PHP using switch case.

Operations:

  • Addition
  • Subtraction
  • Multiplication
  • Division

Click to View Solution/Program

Output:
simple-calculator-program-in-PHP-using-switch-case


Write a PHP program to check if a person is eligible to vote

Description:

Write a PHP program to check if a person is eligible to vote or not.

Condition
Click to View Solution/Program.
OUTPUT :You Are Eligible For Vote

Write a PHP program to check whether a number is positive, negative or zero

Description:

Write a PHP program to check whether a number is positive, negative or zero.

Instructions:

  • You can use if else conditions.
  • You should use appropriate PHP Operators.
  • Also check if it not a numeric value.

Click to View Solution/Program