problems in switch and if commands
Show older comments
Hi guys I am having problems in solving this question can some one help me out please ? :)
I need to use the switch and if commands.
1 Comment
Image Analyst
on 10 May 2013
Edited: Image Analyst
on 10 May 2013
Notice: Charlene edited the vast majority of her question away, probably because it was a homework question.
Accepted Answer
More Answers (1)
Image Analyst
on 9 May 2013
I can do some of it but not all of it for you, because it's your homework, not mine.
rateTable = [...
8500 0 0 11900 0 0
14500 0.15 1275 21200 0.15 1785
19500 0.25 2725 28700 0.25 3905
inf 0.35 4675 inf 0.35 6775]
% Ask user for a number.
defaultValue = 20000;
titleBar = 'Enter a value';
userPrompt = 'Enter your income';
caUserInput = inputdlg(userPrompt, titleBar, 1, {num2str(defaultValue)});
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
income = str2double(cell2mat(caUserInput));
% Check for a valid integer.
if isnan(income)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
income = defaultValue;
message = sprintf('I said it had to be a number.\nI will use %d and continue.', income);
uiwait(warndlg(message));
end
message = sprintf('Are you married');
button = questdlg(message, 'Married?', 'Yes', 'No', 'Yes');
drawnow; % Refresh screen to get rid of dialog box remnants.
if strcmpi(button, 'Yes')
income < rateTable(:, 4)
rowToUse = find(income < rateTable(:, 4), 1, 'first')
deduct = % You do this part
theirRate = % You do this part.
else
income < rateTable(:, 1)
rowToUse = find(income < rateTable(:, 1), 1, 'first')
deduct = % You do this part
theirRate = % You do this part.
end
% Now you compute the tax based on rate and deduct.
Categories
Find more on App Building 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!