For this project we are going to be extending our simple resistor equivalence project to include resistors that are both in series and parallel and in any combination there in. To do this, we will be making use of iteration, selection and functions. The same basic calculations are still the same from last project, but now we need to also have a running total. The total equivalent resistance will be the total sum.
This project is similar to our last project in that we are dealing with resistors and their equivalent values. So when we have resistors in parallel, we can replace that set of parallel resistors with the reciprocal of the sum of their reciprocals. That sum can then be added to our sums of series values. If we encounter another set of parallel resistors, we can simply compute the sum and add it to our total. To accomplish this, we are going to be using functions. I suggest you write one function to sum the parallel resistors and one function to sum the series resistors. Those functions will stop summing when either they run out of input or they encounter one of the characters that indicates we are changing how are resistors are arranged. It might make more sense if we look at how the input might be arranged.
So here are two basic inputs and their description
Notice that series doesn't have to start with an S. It can, but we assume that if the input doesn't start with P or p that it is in series.
Here's a more complicated one.
Like always we need to worry about the output. So here's the output for the cases above
Equivalent Resistance: Total Equivalent Resistance: 9.09091 Ohms Resistor path: Resistors 10.000000 100.000000 in parallel
2.
Equivalent Resistance: Total Equivalent Resistance: 100 Ohms Resistor path: Resistors 50.000000 50.000000 in series
3.
Equivalent Resistance: Total Equivalent Resistance: 97.6768 Ohms Resistor path: Resistors 50.000000 20.000000 in series with 10.000000 20.000000 30.000000 in parallel with 40.000000 50.000000 in parallel
So we compute the equivalent resistance but we also need to keep track of the "path" of the resistors. Some commands you might want to check out are:
We will most likely discuss some or all of these in class, but if you are looking to get a jump on things, that's a good place to see some extra stuff.
So zip up your files and turn them in to Web-CAT. This is due on Wednesday October 15, by 11:55PM