Question : whats wrong her- java program for circuit calculation

Here is a small program to calculate the OHM from electricity and the resistance but something is wrong here in this code, if I try to calculate the Potentiometer than I always get the same result, could some one please help me, thanks,
best regards.

->the main class is called : test.
->there is a interface circuit
->resistor implements circuit
->potentiometer implements circuit and extend the circuit with void setOhm (double ohm) method
->abstract class CompundCircuit contains  the main methods from the serial and extends resistor class.

.-> serial and paralel circuits extends Compound Circuit.


 
 
here my code for circuit program
 

Answer : whats wrong her- java program for circuit calculation

In the Test class you have the following loop at the end:

        for (int ohm = 0; ohm <=500; ohm+=100) {
            c5 = new Potentiometer(ohm);
            Circuit cd = new Parallel(c12345, d);
            System.out.println(c5.getOhm());
            System.out.println(cd.getOhm());

        }

I believe your question is: why is it that, even though I am changing the resistance in the potentiometer c5 for every iteration of the loop, that the resistance for the circuit cd is not changing.

If I am interpreting that right, then the answer is that circuit cd consists of circuits c12345 and d. And since neither c12345 or d is variable, neither will the resistance of cd vary.

I think you meant to make cd out of c12345 and Potentiometer *c5*. If you do that, then the output resistance will vary with each iteration.
Random Solutions  
 
programming4us programming4us