CODE IN JAVA PROGRAMMING
A resistor is an electronic component that impedes the flow of current. The amount of impedance (ignoring any inductive or capacitive qualities) is called resistance and is defined in ohms.
You can combine two resistors together in parallel (both leads--wires coming out of the device--of the resistor are wired together) or in series (one lead of one is connected to only one lead of the other) to create a new effective resistance.
The formula for two resistors in series is:
R efffective=R1 + R2
The formula for two resistors in parallel is:
R efffective=R1R2 / R1+R2
Write a method that calculates the effective resistance for any two resistors, either in parallel or in series. To determine which formula to use pass in either P or S for parallel or series.
Assume that the values provided for the method are "normal," e.g. you do NOT have to anticipate problem conditions.
public static double effectiveR(double r1, double r2,String
type){
if(type.equals("S")){
return r1+r2;
}else if(type.equals("P")){
return 1/(1/r1+1/r2);
}else{
return -1;
}
}
Get Answers For Free
Most questions answered within 1 hours.