+ 2
Who can help me in writing a java program on how to calculate the total resistance of a resistor both in series and parallel
resistor
9 Antworten
+ 4
@ Gaurav
17 variables isn't as many as it sounds. That is what arrays are for. 😜
+ 4
hahaha right @Rrestoring faith
+ 3
This is mainly a input output problem.
* Ask the user how many resistors there are
* Get all information on the resistors (The voltage, or whatever you need)
* Use the formulas to calculate total
* print the total
+ 3
import java.util.Scanner;
public class GauravProgram
{
//input 3 resistances, u can increase no. of resistances in code
//if u want to enter 2 resistances then enter any 1 resistance as 0
public static void main(String[] args) {
double x=0.0,y=0.0,z=0.0;
Scanner sc= new Scanner(System.in);
x=sc.nextDouble();
y=sc.nextDouble();
z=sc.nextDouble();
double series=x+y+z;
double parallel=1/x + 1/y +1/z;
parallel /=1;
System.out.println ("if in series then equivalent resistance is "+ series + "\n"+ "if in parallel then eq. resistance is" +parallel);
}
}
//it will work @fortunatus
+ 3
@bro ipang ,
u can see you tube videos on simple circuits which include only resistances , wire & battery eliminator for more information
@fortuntas ,
then we will have to take 20 inputs and for taking them we need to declare 17 more variables ...
might there be a way for doing it in a simple way ... i don't know ... i will wait for someone who will be able solve it
+ 2
@Gaurav Agrawal, I don't understand this part:
parallel /=1;
Why is that? did it mean parallel = parallel /1? but any number divided by one is its own? help me understand please. Thanks.
+ 2
@Gaurav, thanks for explaining, I don't know parallel resistance formula.
Thanks bro @Gaurav
+ 1
bro , it means parallel = 1/ parallel ;
if u know the formula for parallel resistance , then u can easily figure it out 😊
@Ipang
+ 1
what about resistors up to 20