how can i enter this question in a script file using the if,elseif and else statement?

suppose the abc bank offers 9% interest on balances of less than R5000,12% for balances of R5000 or more but less than R10000,and 15% for balances of R10000 or more.

Answers (2)

I'd use inputdlg() to ask your question to the user. You can ask the user for their balance, and other things if you want on the same dialog box. Then use an if statement
caUserResponse = inputdlg('Enter your balance', 'title' );
balance = str2double(cell2mat(caUserResponse))
if balance < 9000
interest = 0.09
elseif balance < 10000
interest = 0.12
else
interest = 0.15
end

2 Comments

can u please help me to put this information in a script file using the if funtion"12% for balances of R5000 or more but less than R10000"
look at this example
k=input('enter value of k')
if k<0
y=0
elseif k>=0 & k<10
y=1
else
y=2
end

Sign in to comment.

Categories

Find more on Scope Variables and Generate Names in Help Center and File Exchange

Asked:

on 16 Apr 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!