I can't figure out how to ask for the number of resistors that has to be an integer up to 10 and then use a loop to enter R1, R2, ... Rn
1 view (last 30 days)
My homework says to ask if the combination is in series or parallel and I believe I have that done but then I need it to ask for the number of resistors (integer up to 10) and also use a loop to enter R1, R2, ...Rn
So far I have
C=input('Input if the combination is in series or parallel: ','series','parallel');
n=input('Enter the number or resistors');
>> while n=int32(n)
n=input('Enter the number of resistors: ');
fprintf('Enter an integer up to 10')
I'm not sure if this is even right for n and can't figure out how to ask the user to input value for R1, R2...
Joel Bay on 17 Feb 2020
Just need to prompt the user for each resistor, changing the prompt via format specifiers.
for i = 1:n
msg = sprintf('Enter Resistance of Resistor R%d: ', i);
R(i) = input(msg);