Code Chef ATM Problem Solved With PHP
you can read the problem statement here.
Solution:<?php
$ip = fopen('php://stdin', "r");
$op = fopen('php://stdout',"w");
while(!feof($ip)){
$ip_val = trim(fgets($ip));
$vv = explode(" ",$ip_val);
$amt = trim($vv[0]);
$bal = trim($vv[1]);
if((($amt%5) !== 0) || (($amt + 0.5) > $bal) || ($amt < 0) || ($amt > 2000) || ($bal < 0) || ($bal > 2000) ){
fwrite($op, sprintf("%.2f\n", $bal));
}else{
$left = $bal - $amt - 0.50;
fwrite($op, sprintf("%.2f\n", $left));
}
}
?>