php pr2
php pr2
echo ($a && $b) ? "Both are true\n" : "At least one is false\n";
echo ($a || $b) ? "At least one is true\n" : "Both are false\n";
echo ($a xor $b) ? "Only one is true\n" : "Both are either true or false\n"; ?>
Output:
At least one is false At least
one is true a is true Only
one is true
$number = -5;
if ($number > 0)
{
echo "$number is Positive";
}
elseif ($number < 0)
{
echo "$number is Negative";
}
else
{
echo "The number is Zero";
}
?>
Output:
-5 is Negative
Output:
Three
Output:
40 is the largest
5. Write a java program to input electricity unit charges and calculate total Electricity Bill
according to the given condition:
for first 50 unit Rs.0.50/unit
for next 100 unit Rs.0.75/unit
for next 100 unit Rs.1.20/unit
for unit above 2.50 Rs.1.50/unit
An additional subcharge of 20% is added to the bill
import java.util.Scanner;
double bill = 0;
else
Output:
Enter electricity units consumed: 300
Total Electricity Bill: Rs. 420.0