function validate()
{
    if (!isNaturalNumber(document.byc.c, " for the current price."))
    {
        return false;
    }

    if (!isNaturalNumber(document.byc.p, " for the Par value."))
    {
        return false;
    }

    if (!isNaturalNumber(document.byc.n, " for the Years to maturity."))
    {
        return false;
    }

    if (!isValueInRange(document.byc.ytm, 1, 100, " for the Yield to maturity."))
    {
        return false;
    }

    return true;
}

function calc1()
{
    var c = document.byc.c.value;
    var p = document.byc.p.value;
    var n = document.byc.n.value;
    var y1 = document.byc.ytm.value;
    var r = ((y1 / 100 * (0.4 * p + 0.6 * c)) - ((p - c) / n)) / p;
    document.byc.r.value = round(r * 100, 2);
}

function clean()
{
    document.byc.c.value = "";
    document.byc.p.value = "";
    document.byc.r.value = "";
    document.byc.n.value = "";
    document.byc.ytm.value = "";
}
