Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • General idea how ATM Machine Works

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 515
    Comment on it

    This blog will help the readers to understand that how ATM machine dispatches the money. Lets have a look on the ATM code in PHP:

    <?php
    
    $amount = $_REQUEST['amount'];
    $rupees = array(1000,500,100,50,20,10);
    $count  = array(0,0,0,0,0);
    
    for($i=0;$i<count($rupees);$i++):
        if( $rupees[$i] < $amount || $rupees[$i] == $amount ):
            $count[$i] = floor($amount/$rupees[$i]);
            $amount = $amount%$rupees[$i];
        endif;
    endfor;
    
    
    if($amount==0):
        for($i=0;$i<count($count);$i++):
    
            if($count[$i]!=0):
    
                echo ($rupees[$i].' * '.+$count[$i] .'='. ($rupees[$i]*$count[$i])).'<br>';
                $tot += $rupees[$i]*$count[$i];
            endif;
        endfor;
    
        else:
            print '<b>Invalid Amount '.$_REQUEST['amount'].'</b>';
    endif;
    
    ?>
    

    <!DOCTYPE>
    <html>
        <head>
            <title>ATM MACHINE</title>
        </head>
        <body>
            <form name="frm" method="post" action="#">
                Enter value:<input type="text" name="amount" value="" />
                <input type="submit" name="submit" value="submit" />
            </form>
        </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: