for some reasons this code doesnt want to work, what i am doing wrong here please help
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% function returns two params saving and company contributed savings
function [saving,companySaving] = fileSal(sal)
if sal >= 100000
saving = 0.1*60000 + 0.08*40000;
companySaving = 0;
elseif sal >= 60000
saving = 0.1*60000 + 0.08*(sal - 60000);
companySaving = 0.1*30000 + 0.05*30000;
elseif sal >= 30000
saving = 0.1*sal;
companySaving = 0.1*30000 + 0.05*(sal - 30000);
else
saving = 0.1*sal;
companySaving = 0.1*sal;
end
end
% code ends here
0 commentaires
Réponse acceptée
Kevin Holly
le 29 Oct 2022
What issues are you having with the code?
The function doesn't produce any errors for me. Are the answers unexpected?
[saving,companySaving] = fileSal(100000)
[saving,companySaving] = fileSal(59000)
[saving,companySaving] = fileSal(2134)
[saving,companySaving] = fileSal(1335)
function [saving,companySaving] = fileSal(sal)
if sal >= 100000
saving = 0.1*60000 + 0.08*40000;
companySaving = 0;
elseif sal >= 60000
saving = 0.1*60000 + 0.08*(sal - 60000);
companySaving = 0.1*30000 + 0.05*30000;
elseif sal >= 30000
saving = 0.1*sal;
companySaving = 0.1*30000 + 0.05*(sal - 30000);
else
saving = 0.1*sal;
companySaving = 0.1*sal;
end
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!