computer science HW lab report

profilefaisal0z
lab-07_cpp-resistance_noloop.pdf

ECE-206 (Friday), Spring 2016 Exercise #07 Page 1 of 1

Exercise #07: C++ Programming - Series and Parallel Resistance

Value Accumulation without using Array

Prelab: Preliminary flowchart and C++ Program.

The fundamental Laws in Electrical Engineering concerning equivalent resistance are:

Resistors connected in series: Req = R1 + R2 + … + Rn-1 + Rn

Resistors connected in parallel: 1/Req = 1/R1 + 1/R2 + … + 1/Rn-1 + 1/Rn

Draw and code the flowchart to calculate the resistance of resistors connected either in series or

parallel. Do not use array in solving the problem.

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 format specified below.

6. Avoid division by 0.

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 integer portion plus three digits

after the decimal point and the KOHM unit. Example: 2.123 KOhm

Material to Submit

Post Lab:

1. Neatly drawn flowchart

2. Well documented and correct C++ program.

As always, have the instructor verify that your program work as intended.