how can i enter this question in a script file using the if,elseif and else statement?
Show older comments
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)
Image Analyst
on 16 Apr 2013
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
Azzi Abdelmalek
on 16 Apr 2013
0 votes
2 Comments
matome
on 16 Apr 2013
Azzi Abdelmalek
on 16 Apr 2013
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
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!