1) By using a header file for the computation of the resistance, create a script with if, else if, and else conditionals to calculate the Total Resistance (R_T), when r1 = 10 Ω, r2 = 20 Ω, and r3 = 30 Ω. 1) r1 , r2, and r3 are connected in series manner. (R_T= r1+r2+r3) 2) r1, r2, and r3 are connected in parallel manner.(R_T = 1/((1/r1)+(1/r2)+(1/r3)) ) 3) r1 is connected to the parallelly connected r2 and r3 in series manner. (Let’s call this Combination) (R_T = r1 + r2xr3/(r2+r3) ) The user should be prompted to type in the values of r1, r2, r3 and the choice of the connection. Based on the choice of connection in your script, your script should generate ONLY ONE output out of these followings with the numerical result. The Total Resistance is [your result] ohms since r1, r2, r3 are connected in series manner. OR The Total Resistance is [your result] ohms since r1, r2, r3 are connected in parallel manner. OR The Total Resistance is [your result] ohms since r1, r2, r3 are connected in combination manner
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
when r1 = 10 Ω, r2 = 20 Ω, and r3 = 30 Ω.
1) r1 , r2, and r3 are connected in series manner. (R_T= r1+r2+r3)
2) r1, r2, and r3 are connected in parallel manner.(R_T = 1/((1/r1)+(1/r2)+(1/r3)) )
3) r1 is connected to the parallelly connected r2 and r3 in series manner. (Let’s call this
Combination) (R_T = r1 + r2xr3/(r2+r3) )
The user should be prompted to type in the values of r1, r2, r3 and the choice of the connection.
Based on the choice of connection in your script, your script should generate ONLY ONE output out of
these followings with the numerical result.
The Total Resistance is [your result] ohms since r1, r2, r3 are connected in series manner.
OR
The Total Resistance is [your result] ohms since r1, r2, r3 are connected in parallel manner.
OR
The Total Resistance is [your result] ohms since r1, r2, r3 are connected in combination manner.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
How do you redo the above script into one that computes the resistance using a header file?