The equivalent resistance of series and parallel connections of two resistances are given
by the formula:
(a) R1 = r1 + r2 (Series)
(b) R2 = (r1 * r2) / (r1 + r2) (Parallel)
Write a java program to input the value of r1 and r2. Calculate and display the output of the equivalent
resistance as per User's choice.
Answers
Answer:
parallel resistor equation
Explanation:
If the two resistances or impedances in parallel are equal and of the same value, then the total or equivalent resistance, RT is equal to half the value of one resistor. That is equal to R/2 and for three equal resistors in parallel, R/3, etc.
import java.util.*;
public class Resistances
{
public static void main (String args [])
{
Scanner in = new Scanner (System.in);
int n;
double r1, r2, rs, rp;
System.out.println(" enter 1 for series resistance, enter 2 for parallel resistance");
System.out.println("enter your choice:");
n = in.nextInt();
switch (n)
{
case 1:
System.out.println(" enter the value of r1 and r2:");
r1 = in.nextInt();
r2 = in.nextInt();
rs = r1+r2;
System.out.println("Resistance in series =" +rs);
break;
case 2:
System.out.println(" enter the value of r1 and r2:");
r1 = in.nextInt();
r2 = in.nextInt();
rp = (r1*r2)/(r1+r2);
System.out.println(" Resistance in parallel =" +rp);
break;
default:
System.out.println(" Wrong Choice !!!");
}
}
}