Construct the statement on MATLAB: If a person has more than 10 apples then he will sell 8. But if he has less than 10 apples than he will sell 5 apples
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Construct the statement on MATLAB: If a person has more than 10 apples then he will sell 8. But if he has less than 10 apples than he will sell 5 apples.
0 Commenti
Risposte (1)
Wan Ji
il 21 Ago 2021
apples_left = 20; % total apples at the beginning
while true
if(apples_left<5)
break;
end
if(apples_left>10)
apples_sold = 8;
elseif(apples_left<=10)
apples_sold = 5;
end
apples_left = apples_left - apples_sold;
fprintf('apples_sold = %d, apples_left=%d\n', apples_sold, apples_left)
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!