Hi,

This is my attempt to comply with the tests Matthew posted last night.



#!/usr/bin/ruby

def bodgy_rounding(amt)

        if amt >= 0.0  
                x = amt % 5.0
                y = amt - x
                round = x > 2.0 ? y+5 : y
                rem = round - amt

        elsif amt > -3.0
                rem = 0.0 - amt
                round = 0.0 
        else
                rem = 0.0
                round = amt
        end

        return [round, rem]
         
end


def money_breakup(amt)

        a = [0, 0, 0, 0]
        j = 3
        for i in [50, 20, 10, 5]
                a[j] = amt / i
                amt = amt - ( i * a[j] )
                j = j -1
        end

        if amt != 0.0
                puts "Error invalid amount entered"
        end

        return a
end

-- 
Regards,

Graham Smith
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to