Program Pemecahan Uang menggunakan PHP
By: Oky Saputra
Program pecahan uang ini berfungsi untuk menentukan berapakah saja jumlah yang diperlukan untuk nominal tertentu.
Misalkan pecahan uang 150rb diinputkan maka pecahan yang dibutuhkan adalah uang 100000 satu lembar dan 50 rb 1 lembar, ok untuk lebih jelasnya kita lihat gambar dibawah:
Program pecahan uang ini berfungsi untuk menentukan berapakah saja jumlah yang diperlukan untuk nominal tertentu.
Misalkan pecahan uang 150rb diinputkan maka pecahan yang dibutuhkan adalah uang 100000 satu lembar dan 50 rb 1 lembar, ok untuk lebih jelasnya kita lihat gambar dibawah:
Dan untuk source codenya dibawah :
<!Doctype html>
<html lang="en">
<head>
<title>Hitung nilai pecahan uang</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
td{
text-align:center;
}
</style>
</head>
<body>
<div class="jumbotron">
<center><h1>Menghitung uang dalam pecahan rupiah</h1></center>
</div>
<div class="container">
<center>
<div class="row">
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<form method="POST" action="" role="form">
<div class="form-group">
<label>Masukan nilai Uang : </label>
<input type="text" name="uang" class="form-control"><br>
<input type="submit" value="inputkan" class="btn btn-default">
</div>
</form>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
</div>
</center>
<center>
<div class="row">
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<?php
if (!isset($_POST['uang'])){
$uang = 0;
}else{
$uang = $_POST["uang"];
}
if ($uang < 100){
echo "Uang tidak boleh kurang dari 100 rupiah";
}else {
echo "
<p>
<table class = 'table' border=0>
<tr>
<th>
Lembar
</th>
<th>
Pecahan
</th>
</tr>
";
if ( $uang >= 100000){
$nilai_uang = floor(($uang / 100000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_100rb.jpeg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 100000;
if ( $uang >= 50000 && $uang < 100000){
$nilai_uang = floor(($uang / 50000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_50rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 50000;
if ( $uang >= 20000 && $uang < 500000){
$nilai_uang = floor(($uang / 20000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_20rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 20000;
if ( $uang >= 10000 && $uang < 20000){
$nilai_uang = floor(($uang / 10000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_10rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 10000;
if ( $uang >= 5000 && $uang < 10000){
$nilai_uang = floor(($uang / 5000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_5rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 5000;
if ( $uang >= 2000 && $uang < 5000){
$nilai_uang = floor(($uang / 2000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_2rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 2000;
if ( $uang >= 1000 && $uang < 2000){
$nilai_uang = floor(($uang / 1000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_seribu.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 1000;
if ( $uang >= 500 && $uang < 1000){
$nilai_uang = floor(($uang / 500));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_500rupiah.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 500;
if ( $uang >= 200 && $uang < 5000){
$nilai_uang = floor(($uang / 200));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_200rupiah.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 200;
if ( $uang >= 100 && $uang < 2000){
$nilai_uang = floor(($uang / 100));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_100rupiah.JPG' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
echo "</table>";
}
?>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
</div>
</div>
</center>
</div>
</html>
<html lang="en">
<head>
<title>Hitung nilai pecahan uang</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
td{
text-align:center;
}
</style>
</head>
<body>
<div class="jumbotron">
<center><h1>Menghitung uang dalam pecahan rupiah</h1></center>
</div>
<div class="container">
<center>
<div class="row">
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<form method="POST" action="" role="form">
<div class="form-group">
<label>Masukan nilai Uang : </label>
<input type="text" name="uang" class="form-control"><br>
<input type="submit" value="inputkan" class="btn btn-default">
</div>
</form>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
</div>
</center>
<center>
<div class="row">
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
<?php
if (!isset($_POST['uang'])){
$uang = 0;
}else{
$uang = $_POST["uang"];
}
if ($uang < 100){
echo "Uang tidak boleh kurang dari 100 rupiah";
}else {
echo "
<p>
<table class = 'table' border=0>
<tr>
<th>
Lembar
</th>
<th>
Pecahan
</th>
</tr>
";
if ( $uang >= 100000){
$nilai_uang = floor(($uang / 100000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_100rb.jpeg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 100000;
if ( $uang >= 50000 && $uang < 100000){
$nilai_uang = floor(($uang / 50000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_50rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 50000;
if ( $uang >= 20000 && $uang < 500000){
$nilai_uang = floor(($uang / 20000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_20rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 20000;
if ( $uang >= 10000 && $uang < 20000){
$nilai_uang = floor(($uang / 10000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_10rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 10000;
if ( $uang >= 5000 && $uang < 10000){
$nilai_uang = floor(($uang / 5000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_5rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 5000;
if ( $uang >= 2000 && $uang < 5000){
$nilai_uang = floor(($uang / 2000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_2rb.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 2000;
if ( $uang >= 1000 && $uang < 2000){
$nilai_uang = floor(($uang / 1000));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_seribu.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 1000;
if ( $uang >= 500 && $uang < 1000){
$nilai_uang = floor(($uang / 500));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_500rupiah.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 500;
if ( $uang >= 200 && $uang < 5000){
$nilai_uang = floor(($uang / 200));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_200rupiah.jpg' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
$uang = $uang % 200;
if ( $uang >= 100 && $uang < 2000){
$nilai_uang = floor(($uang / 100));
echo "
<tr>
<td>$nilai_uang</td>
<td><img src='images/uang_100rupiah.JPG' class='img-rounded' width='100' height='50'></td>
</tr>
";
}
echo "</table>";
}
?>
</div>
<div class="col-sm-4 col-xs-4 col-md-4 col-lg-4">
</div>
</div>
</div>
</center>
</div>
</html>
Terimakasih Semoga membantu
No comments:
Post a Comment