function debtoincome() {
	var f = document.forms[0];
	var inc = new Number(f.income.value);
	var al  = new Number(f.alimony.value);
	var oi  = new Number(f.otherincome.value);
	var ti  = inc + al + oi;
	var hs  = new Number(f.housing.value);
	var cc  = new Number(f.creditcards.value);
	var al  = new Number(f.autoloans.value);
	var oe  = new Number(f.other.value);
	var te  = hs + cc + al + oe;
	
	var ans,prb,comm;
		
	if ((ti =="") || (te == "") || (isNaN(ti)) || (isNaN(te)))
		alert('Please enter valid numbers and try again.');
	else {	
		prb = te/ti;
		ans = Math.round(100*prb);		

		f.answer.value = ans +"%";
		f.answer.focus();
	}	
}
function cwCalc()
{
if (cwBalance.value=='') {alert('Please enter your credit card balance.'); return;}
if (cwRate.value=='') {alert('Please enter your credit card\'s interest rate.'); return;}
if ( (cwMonthlyAmount.value=='' && cwDesiredMonths.value=='') || (cwMonthlyAmount.value!='' && cwDesiredMonths.value!='') ) {alert('Please enter either a payment amount or desired months.'); return;}
var mRate=(cwRate.value/100)/12;
if (cwMonthlyAmount.value=='')
{
	var payment=cwBalance.value*(mRate)/( 1-Math.pow((1+mRate),(-cwDesiredMonths.value)) );
	payment=Math.round(payment*100)/100;
	cwResult.innerHTML="It will cost $" + payment.toFixed(2) + " a month to pay off this card and will cost you a total of $" + (payment*cwDesiredMonths.value).toFixed(2) + ".";
} else {
	var remainingBalance=cwBalance.value;
	var minPayment=mRate*cwBalance.value;
	var months=0;
	var lastPayment;
	if (minPayment>cwMonthlyAmount.value) {alert ('Your monthly payment is less than the monthly interest charged by this card.');return;}
	while (remainingBalance>0)
	{
		months++;
		remainingBalance=remainingBalance*(1 + mRate)-cwMonthlyAmount.value;
	}
	cwResult.innerHTML="It will take " + months + " months to pay off this card and will cost you a total of $" + (cwMonthlyAmount.value*months).toFixed(2) + ".";
}
}