Basically, I am writting a code that calculates the mass of a pulley. However, t
ID: 3637242 • Letter: B
Question
Basically, I am writting a code that calculates the mass of a pulley. However, the mass will be different depending on the material, type of hub, etc. Therefore, I have to have these requirements as inputs for the user. However, my code wont go past the first "if" statement and it does not perform the first "else" statement either. It just keeps repeating "Enter Material Type (St, Al, Cl). If anyone has any suggestions, please help me out. My code is as follows:material = input('Enter Material Type (St, Al, CI): ');
if material==St
q = 0.2854;
elseif material==Al
q = 0.0975;
elseif material==CI
q = 0.2601;
else
disp (' Incorrect input. Try again');
end
raw = input('Is raw material a casting (c) or cut from a bar (b)?: ');
if raw==b
rd = input('Enter bar diameter: ');
rl = input('Enter bar length: ');
Vr = (pi)*(rd)^2*(1/4)*(rl);
elseif raw==c
rpde = 0.25;
rple = 0.25;
rhde = 0.25;
rhle = 0.25;
Vr = (pi)*(Pod)^2*(1/4)*(Pw) + (pi)*(Hod)^2*(1/4)*(Hw) + rpde + rple + rhde + rhle;
end
cs = input('Which belt cross-section is used (HA, HB, HC, or HD)?: ');
if cs==HA
GA = 32;
TW = 0.490;
GD = 0.490;
elseif cs==HB
GA = 32;
TW = 0.630;
GD = 0.580;
elseif cs==HC
GA = 34;
TW = 0.879;
GD = 0.780;
elseif cs==HD
GA = 34;
TW = 1.259;
GD = 1.060;
end
pod = input('Enter pully outside diameter: ');
pw = input('Enter pully width: ');
hod = input('Enter hub outside diameter: ');
hw = input('Enter hub width: ');
hd = input('Enter hole diameter: ');
V = 2*((pi)*(Pod)^2*(1/4)*((Pw-TW)/2))-(pi)*(hd)^2*(1/4)*(Pw + Hw)+ (2*(1/3)*(pi))*((Pod/2)^2 + ((Pod-2*GD)/2)^2 + ((Pod-2*GD)/2)^2*(Pod/2))*(GD*tan(GA/2)) + ((pi)*((Pod-2*GD)/2)^2*(TW-2*GD*tan(GA/2))) + (pi)*(Hod)^2*(1/4)*(Hw);
mr = Vr*q
mp = V*q
Explanation / Answer
Make the following change to accept string inputs:
material = input('Enter Material Type (St, Al, CI):','s');
Strings should always have single quotation marks around them so change all the if and else statements containing string inputs as follows:
if material=='St' [Enclose in single quotation marks]
It should work after this.
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.