01.
$sum
= 0;
02.
$difference
= 0;
03.
echo
"<br> ค่าน้ำ = "
;
04.
echo
$x
= 40;
05.
echo
" หน่วย "
;
06.
$a1
= 10;
$pire1
= 16 ;
07.
$a2
= 10;
$pire2
= 19 ;
08.
$a3
=10;
$pire3
= 20;
09.
$a4
=0;
$pire4
=22;
10.
$difference
=
$x
-
$a1
;
11.
if
(
$difference
>=
$a1
) {
12.
echo
"<br> 10หน่วยแรก = "
;
13.
echo
$sum
=
$sum
+ (
$a1
*
$pire1
);
14.
echo
" "
;
15.
echo
$difference
=
$difference
-
$a2
;
16.
}
17.
if
(
$difference
>=
$a2
) {
18.
echo
"<br> 10หน่วยที่ 2 = "
;
19.
echo
$sum
=
$sum
+ (
$a2
*
$pire2
);
20.
echo
" "
;
21.
echo
$difference
=
$difference
-
$a3
;
22.
}
23.
24.
if
(
$difference
>=
$a3
) {
25.
echo
"<br>10หน่วยที่ 3 = "
;
26.
echo
$sum
=
$sum
+ (
$a3
*
$pire3
);
27.
echo
" "
;
28.
echo
$a4
=
$difference
;
29.
}
30.
echo
"<br>ค่าน้ำหน่วยที่เหลือ = "
;
31.
echo
$sum
=
$sum
+ (
$a4
*
$pire4
);
32.
echo
"<br>"
;
33.
echo
"ค่าน้ำทั้งหมด = "
;
echo
$sum
;