Question: Using a while loop, allow the user to input as many numbers as they want (one number per iteration). When they are done, they should
Using a while loop, allow the user to input as many numbers as they want (one number per iteration). When they are done, they should type a -1 to quit. Store the sum of all entered numbers greater than 7. Output the sum using the fprintf command.
Below is the code used to calculate the volume of the half pipe. Convert this code using a while loop to allow the user to 1) input as many numbers as they want 2) Be able to type -1 to quit 3)Store the sum of all entered numbers greater than 7 4) Output the sum using the fprintf command
length = input('Please enter the length in inches: '); od = input('Please enter the outer diameter in inches: '); id = od*0.8; vol_outer = .5*pi*((od/2)^2)*length; vol_inner = .5*pi*((id/2)^2)*length; vol = vol_outer - vol_inner; v_gals = vol/231; fprintf('\t The volume inside this half cylinder is %1.4f gallons. ',v_gals)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
