An orange farm usually package their fruits in a box of 10 oranges before shippi
ID: 2320030 • Letter: A
Question
An orange farm usually package their fruits in a box of 10 oranges before shipping them out to their customers. However, the shipping company charges extra if the boxes weighs 1.5kg or more. Therefore, write a Matlab script that is able to help the farm sort out the boxes that are 1 5kg or heavier so that they can be repackaged with lighter oranges. The program should continuously request for the user to input the weight of each orange and when the total weight for a box of oranges have been entered, a message will be displayed to determine if the box is overweight or not. This should be done for 20 boxes of oranges.Explanation / Answer
MATLAB code:
clear all
close all
clc
for i=1:20
twt=0;
for j=1:10
wt_ip= input('Enter orange weight : ');
twt=twt+wt_ip;
end
if twt>1.5
disp('Box is overweight')
else
disp('Box is not a overweight')
end
end
sample outputs:
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.2
Enter orange weight : 0.3
Enter orange weight : 0.1
Enter orange weight : 0.4
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.3
Box is overweight
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.1
Enter orange weight : 0.15
Enter orange weight : 0.25
Enter orange weight : 0.1
Enter orange weight : 0.2
Box is not a overweight
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.