+ 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

24th Aug 2017, 12:25 AM
fortunatus
fortunatus - avatar
9 ответов
+ 4
@ Gaurav 17 variables isn't as many as it sounds. That is what arrays are for. 😜
24th Aug 2017, 4:22 PM
Rrestoring faith
Rrestoring faith - avatar
+ 4
hahaha right @Rrestoring faith
25th Aug 2017, 2:52 AM
Changed
Changed - avatar
+ 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
24th Aug 2017, 2:48 AM
Rrestoring faith
Rrestoring faith - avatar
+ 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
24th Aug 2017, 4:59 AM
Changed
Changed - avatar
+ 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
24th Aug 2017, 3:44 PM
Changed
Changed - avatar
+ 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.
24th Aug 2017, 7:04 AM
Ipang
+ 2
@Gaurav, thanks for explaining, I don't know parallel resistance formula. Thanks bro @Gaurav
24th Aug 2017, 2:27 PM
Ipang
+ 1
bro , it means parallel = 1/ parallel ; if u know the formula for parallel resistance , then u can easily figure it out 😊 @Ipang
24th Aug 2017, 9:12 AM
Changed
Changed - avatar
+ 1
what about resistors up to 20
24th Aug 2017, 2:17 PM
fortunatus
fortunatus - avatar