Ok well my assignment is to write a program to gives me the total resistance in a circuit.

The user is prompted for the resistance type and resistor value such as <1 200> 1 meaning in series, and 200 being the value of the resistor. When the user imputs -1 for the type the program stops and gives the total resistance. 0 goes for the starting resistor, then 1 is for series, and 2 for parallel. Here is what i have so far, I know its not calculating correctly and I can understand what to do in my head, I just cant translate it to code :/ any help or suggestions would be great, thanks :)

An example of what a user would input would be

"Input resistance type(0 starting: 1 series: 2 parallel) and resistor value"

0 100

1 100

1 100

2 200

2 200

1 25

2 200

1 50

-1

"total resistance is" 100

```
#include <iostream>
using namespace std;
int main(){
int code=0; //This is the connectivity type
double rv=0;//This is the resistor value
double total=0;
double sumD=0; //Sum of the denominator
while (code!=-1){
cout<<"Input connectivity type(0 starting: 1 series: 2 parallel) and Resistor Value:";
cin>>code>>rv;
if (code==1){
total += rv;}
else {
sumD += 1.0/rv;}
}
if (code==2){
total += 1.0/(sumD);}
cout<<total<<endl;
return 0;}
```