2a. (20 points) A party store sells helium tanks to fill spherical balloons. Wri
ID: 3805766 • Letter: 2
Question
2a. (20 points) A party store sells helium tanks to fill spherical balloons. Write a function that accepts two inputs: a vector of balloon diameters in inches and a scalar ofa helium tank size in cubic feet. The helium tank cannot fill balloons with diameters smaller than 6 inches, so your function should remove those diameters from the vector parameter and the table displayed. The function displays a table showing the size of balloon, volume of the balloon in cubic feet, and number of balloons of each diameter that size of tank can fill. Volume ofa sphere (43) pir 3. The function should calculate the total volume of each balloon in cubic feet calculate the of balloons ofeach diameter the helium tank will fill display a of table of balloon diameter, balloon volume (cubic feet #of each size of balloon helium tank will fill Do not worry about formatting the output to a specific number of decimal places.Explanation / Answer
function[] = fun(a, tankSize)
fprintf('dia vol no of balloons ')
for i=1:numel(a)
if a(i)<6
continue; %discard smaller balloons
end
volBal = 4/3*pi*(a(i)/2)^3; %find volume
fprintf('%d %d %d ',a(i),volBal,floor(tankSize/volBal)); %print valid balloons. note the useage of floor
end
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.