/* ACTION 7-2 (ACT07_02.CPP) THIS PROGRAM WILL FIND THE EQUIVALENT RESISTANCE FOR ANY NUMBER OF RESISTORS IN A PARALLEL CIRCUIT */ //PREPROCESSOR DIRECTIVE #include //FOR cin AND cout //MAIN FUNCTION int main() { //DEFINE VARIABLES int count = 0; //LOOP COUNTER int number = 0; //NUMBER OF RESISTORS IN CIRCUIT double R_equiv = 0.0; //RESISTANCE OF CIRCUIT IN OHMS double R = 0.0; //INDIVIDUAL RESISTANCE VALUES IN OHMS //WRITE PROGRAM DESCRIPTION MESSAGE AND GET NUMBER //OF PARALLEL RESISTORS cout << "\nThis program will calculate the equivalent resistance\n" << "of any number of parallel resistors." << endl << endl; cout << "Enter the number of resistors in the parallel circuit: "; cin >> number; //CALCULATE EQUIVALENT RESISTANCE USING WHILE while (count < number) { ++count; cout << "Enter the value for resistor #" << count << ": "; cin >> R; if (count == 1) R_equiv = R; else R_equiv = (R_equiv * R) / (R_equiv + R); } //END WHILE cout.setf(ios::fixed); cout.precision(2); cout << "The equivalent resistance for the parallel circuit is: " << R_equiv << " ohms" << endl; //RETURN return 0; } //END main()