You are on page 1of 7

โจทย์ข้อ 5

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

โค้ด

<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>โปรแกรมคำณวนเงิน (เหรียญ/ธนบัตร)</title>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-
ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">

<link href="https://fonts.googleapis.com/css2?family=SarabunPSK" rel="stylesheet">


<style>
body {
font-family: 'SarabunPSK', sans-serif;
}

</style>
</head>
<body>

<br>
<div class="container">
<h2 class ="text-center">โปรแกรมคำณวนเงิน (เหรียญ/ธนบัตร)</h2>
<h4 class ="text-center">พัฒนาโปรแกรมโดย นาย ปุณยวัจน์</h4>
<form method= "post" >
<p>
<label>
<center>
<div class = "form-group">
เหรียญ 1 &nbsp <input type="text"name="money1" /> เหรียญ
&nbsp <br>
</div>
<div class = "form-group">
<br> เหรียญ 2 &nbsp <input type="text"name="money2" /> เหรียญ &nbsp
<br>
</div>
<div class = "form-group">
<br> เหรียญ 5 &nbsp <input type="text"name="money3" /> เหรียญ &nbsp
<br>
</div>
<div class = "form-group">
<br> เหรียญ 10 &nbsp <input type="text"name="money4" /> เหรียญ &nbsp <br>
</div>
<div class = "form-group">
<br> แบงค์ 20 &nbsp <input type="text"name="money5" /> บาท &nbsp
<br>
</div>
<div class = "form-group">
<br> แบงค์ 50 &nbsp <input type="text"name="money6" /> บาท &nbsp
<br>
</div>
<div class = "form-group">
<br> แบงค์ 100 &nbsp <input type="text"name="money7" /> บาท &nbsp <br>
</div>
<div class = "form-group">
<br> แบงค์ 1000 &nbsp <input type="text"name="money9" /> บาท &nbsp
<br>
</div>

<br>

<input type = "submit" value = "คำณวน" class="btn btn-success">


<input type = "reset" value = "ล้างข้อมูล" class="btn btn-danger">

<br>
</center>
</label>
</p>
</form>
<center>
<?php
isset( $_POST['money1'] ) ? $money1 = $_POST['money1'] : $money1 = "";
isset( $_POST['money2'] ) ? $money2 = $_POST['money2'] : $money2 = "";
isset( $_POST['money3'] ) ? $money3 = $_POST['money3'] : $money3 = "";
isset( $_POST['money4'] ) ? $money4 = $_POST['money4'] : $money4 = "";
isset( $_POST['money5'] ) ? $money5 = $_POST['money5'] : $money5 = "";
isset( $_POST['money6'] ) ? $money6 = $_POST['money6'] : $money6 = "";
isset( $_POST['money7'] ) ? $money7 = $_POST['money7'] : $money7 = "";
isset( $_POST['money8'] ) ? $money8 = $_POST['money8'] : $money8 = "";
isset( $_POST['money9'] ) ? $money9 = $_POST['money9'] : $money9 = "";
$presum1 = (int)$money1 * 1;
$presum2 = (int)$money2 * 2;
$presum3 = (int)$money3 * 5;
$presum4 = (int)$money4 * 10;
$presum5 = (int)$money5 * 20;
$presum6 = (int)$money6 * 50;
$presum7 = (int)$money7 * 100;
$presum8 = (int)$money8 * 500;
$presum9 = (int)$money9 * 1000;
$sum = (int)$presum1 + (int)$presum2 + (int)$presum3 +(int)$presum4 + (int)$presum5 +
(int)$presum6 + (int)$presum7 + (int)$presum8 + (int)$presum9;
echo "จำนวนเงิน&nbsp" . $sum . "&nbspบาท";
?>
</center>
</body>
</html>

โปรแกรมที่ทำงานแล้ว

You might also like