To whom it may concern:
I've run into a small amount of bother with the following Activity.
A bank wants to calculate the interest due to its customers and add this to their accounts.
This is complicated since the interest rate applicable depends on the initial balance, as follows:
Initial balance Interest rate
Less than R1 000 0%
R1 000 to R5 000 5%
R5 000 to R10 000 8%
R10 000 to R20 000 9%
Above R20 000 10%
The original code provided to us to solve this conundrum is as follows:
if (oldbalance < 1000)
rate =0;
elseif (oldbalance <5000)
rate=0.05;
elseif (oldbalance <10000)
rate=0.08;
elseif (oldbalance <20000)
rate=0.09;
else
rate=0.1;
endif
newbalance=oldbalance*(1+rate)
But, when I put this into Octave, I get the following errors...
octave-3.0.0.exe:1> bank1
error: `oldbalance' undefined near line 1 column 5
error: evaluating binary operator `<' near line 1, column 16
error: if: error evaluating conditional _expression_
error: evaluating if command near line 1, column 1
error: near line 11 of file `C:\Program Files (x86)\Octave\bank1.m'
So, I am here trying to get this code to work and this is what I have so far:)
input ('originalbalance = ');
if ('originalbalance = ' < 1000)
rate =0;
elseif ('originalbalance = ' <5000)
rate=0.05;
elseif ('originalbalance = '<10000)
rate=0.08;
elseif ('originalbalance = ' <20000)
rate=0.09;
else
rate=0.1;
endif
newbalance ='originalbalance = '*(1+rate)
This is the output I get then...
octave-3.0.0.exe:4> bank
originalbalance = 12999
newbalance =
111 114 105 103 105 110 97 108 98 97 108 97 110 99 101 32 61 32
octave-3.0.0.exe:5> bank
originalbalance = 12000
newbalance =
111 114 105 103 105 110 97 108 98 97 108 97 110 99 101 32 61 32
What am I missing here?