Skip to content

Instantly share code, notes, and snippets.

@nw
Created September 9, 2015 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nw/e1580bf3acbc9674d3ba to your computer and use it in GitHub Desktop.
Save nw/e1580bf3acbc9674d3ba to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: nw
* Date: 9/8/15
* Time: 8:33 PM
*/
function ATM($withdraw, $balance)
{
$transaction_fee = 0.50;
if(!is_numeric($withdraw) || !is_numeric($withdraw))
{
return $balance;
}
if($withdraw % 5 != 0 )
{
return $balance;
}
$total = $balance - ($withdraw + $transaction_fee);
if ($total > 0)
{
return $total;
}
else
{
return $balance;
}
}
?>
<html>
<head>
<title>Atm</title>
</head>
<body>
<form method="GET">
<input type="text" name="withdraw" placeholder="withdraw" />
<input type="text" name="balance" placeholder="balance" />
<input type="submit" value="Submit" />
</form>
<h1><?php
if(isset($_GET['balance'])){
echo ATM(floatval($_GET['withdraw']), floatval($_GET['balance']));
}
?></h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment