DWPD : Practical 12
1.Write PHP Script to print Fibonacci series.<?php
$a=0;
$b=1;
echo "A = $a , B = $b"."<br>";
echo "Fibonacci series..."."<br>";
for($i=1; $i<=15; $i++)
{
$c=$a+$b;
echo $c.", ";
$a=$b;
$b=$c;
}
?>
Output :
2.Write PHP Script to calculate total marks of sudent and display grade.<html>
<head>
<title>Grade System</title>
</head>
<body>
<form method="post">
DWPD <input type="text" name="dwpd"><br/>
JAVA <input type="text" name="java"><br/>
CM <input type="text" name="cm"><br/>
MAT <input type="text" name="mat"><br/>
<input type="submit" name="submit" value="Get Grade">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$dwpd=$_POST['dwpd'];
$java=$_POST['java'];
$cm=$_POST['cm'];
$mat=$_POST['mat'];
$totalm=70*4;
$total=$dwpd+$java+$cm+$mat;
echo "Marks obtained in DWPD is $dwpd"."<br>";
echo "Marks obtained in JAVA is $java"."<br>";
echo "Marks obtained in CM is $cm"."<br>";
echo "Marks obtained in MAT is $mat"."<br>";
echo "Total marks obtained $total out of $totalm"."<br>";
$average=$total*100/$totalm;
echo "And The result is : ";
switch($average)
{
case $average<=32:
echo "<h1>failed</h1>";
break;
case $average>=33 && $average<=60:
echo "Third class <h1>BB Grade</h1>";
break;
case $average>=60 && $average<=70:
echo "Second class <h1>BA Grade</h1>";
break;
case $average>=70 && $average<=80:
echo "First class<h1>AB Grade</h1>";
break;
case $average>=70 && $average<=100:
echo "Distinction <h1>AA Grade</h1>";
break;
}
}
?>
Output before input :
Output after input :
3.Write PHP Script to find maximum number out of three given numbers.<?php
$a=10;
$b=12;
$c=30;
if($a>$b && $a>$c)
{
echo "a is max";
}
else if($b>$c)
{
echo "b is max";
}
else
{
echo "c is max";
}
?>
Output :
Comments
Post a Comment