Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="cctest.php" method="post">
- <input type="text" placeholder="1000kr" name="onethousand">
- <input type="text" placeholder="500kr" name="fivehundred">
- <input type="text" placeholder="200kr" name="twohundred">
- <input type="text" placeholder="100kr" name="onehundred">
- <input type="text" placeholder="50kr" name="fifty">
- <input type="text" placeholder="20kr" name="twenty">
- <input type="text" placeholder="10kr" name="ten">
- <input type="text" placeholder="5kr" name="five">
- <input type="text" placeholder="2kr" name="two">
- <input type="text" placeholder="1kr" name="one">
- <button type="submit" name="submit">Submit</button>
- </form>
- <?php
- if(isset($_POST['submit'])) {
- $billValues = array(
- $_POST['onethousand'],
- $_POST['fivehundred'],
- $_POST['twohundred'],
- $_POST['onehundred'],
- $_POST['fifty'],
- $_POST['twenty']
- );
- $coinValues = array(
- $_POST['ten'],
- $_POST['five'],
- $_POST['two'],
- $_POST['one']
- );
- $billDenomValues = array(1000, 500, 200, 100, 50, 20);
- $coinDenomValues = array(10, 5, 2, 1);
- $amountOfBills = array_sum($billValues);
- $amountOfCoins = array_sum($coinValues);
- $valueOfBills = 0;
- $valueOfCoins = 0;
- $i = 0;
- while($i < 6) {
- $valueOfBills += $billValues[$i] * $billDenomValues[$i];
- $i++;
- }
- $i = 0;
- while($i < 4) {
- $valueOfCoins += $coinValues[$i] * $coinDenomValues[$i];
- $i++;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement