Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ohm\'s Law models the current through a conductor as follows: I =V/R where V is

ID: 3648545 • Letter: O

Question

Ohm's Law models the current through a conductor as follows:
I =V/R
where V is the voltage (in volts), R is the resistence (in Ohms) and I is the current (in amps). Write a
program that, given two of these values computes the third using Ohm's Law.
The program should work as follows: it prompts the user for units of the rst value: the user should be
prompted to enter V, R, or I and should then be prompted for the value. It should then prompt for the
second unit (same options) and then the value. The program will then output the third value depending
on the input. An example run of the program:
1 Current Calculator
2 ==============
3 Enter the first unit type (V, R, I): V
4 Enter the voltage : 25.75
5 Enter the second unit type (V, R, I): I
6 Enter the current : 72
7 The corresponding resistence is 2.796 Ohms

Explanation / Answer

#include #include #include int main() { char ch; float voltage , current , resistance , result; printf("Ohms law calculator. "); printf("Please choose from following calculcations. "); printf("1. choose 1 to calculate the voltage. "); printf("2. choose 2 to calculate the current. "); printf("3. choose 3 to calculate the resistance. "); printf("Anything else to quit. "); scanf("%c",&ch); switch(ch) { case '1' : printf("please enter the current in amps. "); scanf("%f",¤t); printf("Now enter the resistance in ohms. "); scanf("%f",&resistance); result = current * resistance; printf("The voltage is %0.2f volts. ",result); break; case '2' : printf("please enter the voltage in volts. "); scanf("%f",&voltage); printf("Now enter the resistance in ohms. "); scanf("%f",&resistance); result = voltage / resistance; printf("The current is %0.2f amps. ",result); break; case '3' : printf("please enter the voltage in volts. "); scanf("%f",&voltage); printf("Now enter the current in amps. "); scanf("%f",¤t); result = voltage / current; printf("The resistance is %0.2f ohms. ",result); break; default : exit(0); break; } return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote