Cara I
<html>
<head>
<title> Nilai Angka-Huruf </title>
</head>
<body>
<?php
$n = 87; //misalkan nilai yang diperoleh = 87
if($n<0 or $n>100)
{
print("Nilai Angka = $n <br> Nilai Huruf = Tidak Terdefinisi.");
}
else if($n>=80 and $n<=100)
{
print("Nilai Angka = $n <br> Nilai Huruf = A");
}
else if($n>=70 and $n<80)
{
print("Nilai Angka = $n <br> Nilai Huruf = B");
}
else if($n>=60 and $n<70)
{
print("Nilai Angka = $n <br> Nilai Huruf = C");
}
else if($n>=50 and $n<60)
{
print("Nilai Angka = $n <br> Nilai Huruf = D");
}
else
{
print("Nilai Angka = $n <br> Nilai Huruf = E");
}
?>
</body>
</html>
Cara II
<html>
<head>
<title> Nilai Angka-Huruf </title>
</head>
<body>
<?php
$n = 78; //misalkan nilai yang diperoleh = 78
if($n<0 || $n>100)
{
print("Nilai Angka = $n <br> Nilai Huruf = Tidak Terdefinisi.");
}
else if($n>=80 && $n<=100)
{
print("Nilai Angka = $n <br> Nilai Huruf = A");
}
else if($n>=70 && $n<80)
{
print("Nilai Angka = $n <br> Nilai Huruf = B");
}
else if($n>=60 && $n<70)
{
print("Nilai Angka = $n <br> Nilai Huruf = C");
}
else if($n>=50 && $n<60)
{
print("Nilai Angka = $n <br> Nilai Huruf = D");
}
else
{
print("Nilai Angka = $n <br> Nilai Huruf = E");
}
?>
</body>
</html>
Tampilkan postingan dengan label PHP. Tampilkan semua postingan
Tampilkan postingan dengan label PHP. Tampilkan semua postingan
Rabu, 22 Mei 2013
Perulangan
Cara I
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
for($i=0; $i<=100; $i+=3)
{
print("$i ");
}
?>
</body>
</html>
Cara II
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
for($i=0; $i<=100; $i++)
{
print("$i ");
$i+=2;
}
?>
</body>
</html>
Cara III
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
$i=0;
while($i<=100)
{
print("$i ");
$i+=3;
}
?>
</body>
</html>
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
for($i=0; $i<=100; $i+=3)
{
print("$i ");
}
?>
</body>
</html>
Cara II
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
for($i=0; $i<=100; $i++)
{
print("$i ");
$i+=2;
}
?>
</body>
</html>
Cara III
<html>
<head>
<title> Bilangan 0-100 Selisih 3 </title>
</head>
<body>
<?php
$i=0;
while($i<=100)
{
print("$i ");
$i+=3;
}
?>
</body>
</html>
Langganan:
Postingan (Atom)