This being the first part will have you solve the following problem from Electrical engineering. We will be calculating the combined resistors connected in parallel.

To compute this, we will use the following formula: see image.

where R1, R2 and R3 are the values for the 3 resistors.

You can see from this formula that the value for the resistors cannot be 0. You need to check for this. If any of the resistors has a value of 0, please write a message indicating this error and stop your program.

Using this formula, write a C++ program to request, calculate and display the combined resistance for the three resistors R1, R2 and R3 are connected in parallel.

The output from this formula will simply be the answer as a double.

Your job is going to be to read in a series of numbers each set of doubles will be on a single line. See the example input. You can use extraction (>>) to read each double into a variable.

Input

The input will consist of a series of numbers. There will always be three numbers and the numbers should be considered to be doubles. It will be in a file called "input.txt". Your function should open a file with that name.

1.0 1.0 1.0
.5 .5 .5
0 1.0 .5

Are three sample inputs.

Output

If you entered one of the inputs above then this is the output from your program. Your program should use a file called "output.txt".

0.333333
0.166667
--error--

The output is just the answer to the problem, if none of the resistor values are 0 or the word --error-- if any of them are 0.

In your computeResistance function, make sure you are using in for your input, not cin. Make sure you are using out for your output not cout. The only exception to using cout would be if you'd like a prompt then use cout.

In order to get this to work, you need to put your functions in a file called:

resistors.h

and you must write a function with the following signature:

void computeResistance();

Here's a file you may use for resistors.h

When you are done, zip up your resistors.h and any implementation files and turn them in for lab 3. Attached below is a main function you could use. I will also attach some input files you could use for testing. You are welcome to write your own main and your own input files. main.cpp

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.