Hi, guys. Could I ask you other question?
Here is my exercise:
quote:
Write a progarm to calculate the interest on a bank account. The interest is:
0% on balances <$1000
1% on balances <=$1000 and <$5000
1.5% on balances <=$5000.
As user error detection, if user enter negative number, get alert saying "Work hard!".
I cannot understand why this code does not work. Then I modified like secode code. Works fine. But I think logically first one is good way to deal with this question. Do you see anything wrong???
code:
function cal(){
if(5000<=form1.acc.value){
form1.int.value=Math.round(0.015*(form1.acc.value-5000)+40);
}else if((1000<=form1.acc.value) && (form1.acc.value<5000)){
form1.int.value=Math.round(0.01*(form1.acc.value-1000));
}else if((0<=form1.int.value)&&(form1.int.value<1000)){
form1.int.value=0;
}else{
alert(" Work hard!!!");
}
code:
function cal(){
if(form1.acc.value<0){
alert("Work hard!!!");
}
if(5000<=form1.acc.value){
form1.int.value=Math.round(0.015*(form1.acc.value-5000)+40);
}else if((1000<=form1.acc.value) && (form1.acc.value<5000)){
form1.int.value=Math.round(0.01*(form1.acc.value-1000));
}else{
form1.int.value=0;
}
Thanks.
Hiroki Kozai