โจทย์ เขียนโปรแกรม

ร้าน Big-C ต้นยาง เปิดร้านใหม่ ต้องการส่งเสริมการขายสินค้า ถ้าลูกค้าซื้อสินค้ารวมเป็นเงินทุกๆ
     800 บาท ได้คูปองส่วนลดสำหรับแลกซื้อครั้งต่อไป 50 บาท โดยการกำจัดคูปอง 3 คูปองต่อ 1
     ใบเสร็จ ถ้านักศึกษาซื้อสินค้ารวมเป็นเงิน 3500 บาท จะได้คูปองกี่ใบ รวมเป็นเงินกี่บาท
          ให้นักศึกษา
1.      วิเคราะห์งาน
รับค่า
     ซื้อสินค้า(totalprice)=3500
    
ประมวลผล
     ส่วนลด (coupong)=totalprice/800
                        =int 3500/800
                        =4
     ตรวจสอบเงื่อนไข
              If (coupon>=3)
                        Discount=coupon(3)*50
                                     =150
แสดงผล
ซื้อสินค้า (totalprice)3500
ส่วนลดคูปอง (coupong) 3
ส่วนลด (discount)=150
2.      เขียนผังงาน

               


3.      เขียนโปรแกรม
Bigc.html
<html>
 <head>
  <title> bigc.html </title>
   </head>
 <body>
  <form method="post" action="bigc.php">
  จำนวนเงินซื้อสินค้าทั้งหมด
  <input type="text"ame="totalprice">
  <input type="submit">
  </form>
 </body>
</html>
            Bigc.php
<html>
 <head>
  <title> bigc.php </title>
 </head>
 <body>

<?php

echo "รวมสินค้าคิดเป็นเงิน" .;
$totalprice = $_POST[totalprice];
$coupong = floor($totalprice / 800);
if ($coupong >= 3)
{
    $coupong = 3;
}
$discount = $coupong * 50;
echo "รวมสินค้าคิดเป็นเงิน" . $totalprice;
echo "ได้คูปอง" . $coupong . "ใบ";
echo "ได้ส่วนลดครั้งต่อไป" . $discount . "บาท";
?>
 </body>

</html>