ECE 1574: Project 2

Requirements

  1. Iteration
  2. Selection
  3. Functions

Background

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.

Details

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.

Input

So here are two basic inputs and their description

  1. P 10 100 == Parallel 10 and 100
  2. 50 50 == Series 50 and 50

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.

  1. 50 20 P 10 20 30 P 40 50 == 50 and 20 in series with 10 20 30 in parallel and 40 50 in parallel

Output

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.

Grading

So zip up your files and turn them in to Web-CAT. This is due on Wednesday October 15, by 11:55PM

Requirements

  1. You must name your header file resist.h
  2. You must have the function void computeResistance( istream& in, ostream& out ); in resist.h
  3. You must write and call two more functions of your own creation.
  4. You must not use the STL, e.g. Vector, but you may use string and the iostreams.
  5. You must process the data as you go, i.e. no storing of your data.