I'm having trouble with—I believe—getting incorrect output from the second part of the bool statement here. The code's running, and I believe the Series Circuit statment is correct, but not the second part..
#include <iostream>
#include <cmath>
#include <iomanip>
usingnamespace std;
int main() {
char C;
char S;
char P;
double R;
double R1;
double R2;
double R3;
double I;
double V=12;
double Rr;
cout << "Please enter S for Series Circuit or P for Parallel Circuit" << endl;
cin >> C;
if (C == 'S') {
cout << "This program will calculate the total resistance (R) given three resistor values (R1,R2,R3) in ohms" << endl;
cout << "Please enter the first resistor value (R1) in ohms:" << endl;
cin >> R1;
cout << "Please enter the second resistor value (R2) in ohms:" << endl;
cin >> R2;
cout << "Please enter the third resistor value (R3) in ohms:" << endl;
cin >> R3;
R = R1+R2+R3;
I = V/R;
cout << "R = " << R << endl;
cout << "I = " << I << endl;
}
elseif (C == 'P') {
cout << "This program will calculate the total resistance (R) given three resistor values (R1,R2,R3) in ohms" << endl;
cout << "Please enter the first resistor value (R1) in ohms:" << endl;
cin >> R1;
cout << "Please enter the second resistor value (R2) in ohms:" << endl;
cin >> R2;
cout << "Please enter the third resistor value (R3) in ohms:" << endl;
cin >> R3;
R = (1/R1) + (1/R2) + (1/R3);
Rr = (1/R);
I = V/R;
cout << "R = " << R << endl;
cout << "I = " << I << endl;
}
}