LAB EXERCISE #6: C++ Programming - Series and Parallel Resistance (Value Accumulation without using Array)
Prelab: Preliminary C++ Program
Prelab: Preliminary flowchart and C++ Program
Tasks:
Introduction: The fundamental Laws in Electrical Engineering concerning resistance are: (1) Resistors connected in series: R = R1 + R2 + R3 + ... + Rn (2) Resistors connected in parallel: 1/R = 1/R1 + 1/R2 + 1/R3 + ... + 1/Rn
Repeat Laboratory Exercise 6 with these modifications:
1. Write a C++ program to calculate the resistance of resistors connected either in series or parallel without using an array. Assume that the program can handle up to 1000 resistors.
2. The print output format of the resistance must satisfy this additional requirement: Print the total resistance followed by the values of each resistor.
Tasks: Draw and code a flowchart to calculate the resistance of resistors connected either in series or parallel. Note: Do NOT use an array in solving the problem.
Example:
Display For series configuration: Total series resistance is 2.123 KOhm for 3 resistors: 1000 Ohm, 1000 Ohm, 123 Ohm.
The flowchart must include the following:
1. Prompt the user to select either the series or the parallel connection.
2. Prompt the user to enter the number of resistors connected.
3. Read (get) the value of each of the resistors.
4. Calculate the resistance.
5. Output the resistance value according to the format specified below.
6. Avoid division by 0.
Display For parallel configuration: Total parallel resistance is 500 Ohm for 2 resistors: 1000 Ohm, 1000 Ohm.
The print output of the resistance must follow this format:
1. If the resistance value is less than 1000, output only the integer portion of the value and the Ohm unit. Example: 235 Ohm
2. If the resistance value is greater than or equal to 1000, output the integer portion plus three digits after the decimal point and the KOhm unit. Example: 2.123 KOhm
Show Instructor or Lab Assistant: Show a well-documented and correct C++ program, and run output to verify that your program works as intended.
In-lab Requirement: As always, have the instructor or teaching assistant verify that your program works as intended.
The Question is the one on the right. And please do not forget to Draw the FlowChart