51
1
/*I Mctavish - 2017/08/24
2
Calculate V, R or I based on Ohm's Law*/
3
using System;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
Console.WriteLine("What are you trying to find? Potential (V), current (I) or resistance (R)");
10
11
string unitToFind = Console.ReadLine();
12
if(unitToFind == "V")
13
{
14
Console.WriteLine("Enter the Resistance as a decimal number");
15
double R;
16
while(!double.TryParse(Console.ReadLine(),out R));
17
Console.WriteLine("Enter the Current (amperage) as a decimal number");
18
double I;
19
while(!double.TryParse(Console.ReadLine(),out I));
20
double V = R*I;
21
Console.WriteLine("Potential Voltage is: " + V.ToString() + " Volts");
22
}else if(unitToFind == "I")
23
{
24
Console.WriteLine("Enter the Potential Voltage as a decimal number");
Cached Result
Environment version: .NET 9.0.0 (9.0.0, Unix 6.8.0.1014)
<Root>‘<!--?--></Root>
<Root>‘<!--?--></Root>
<Root>‘<!--'--></Root>
<Root>‘<!--‘--></Root>
<Root>‘<!--‘--></Root>
<Root>‘<!--‘--></Root>
<Root>‘<!--?--></Root>
<Root>‘<!--?--></Root>
<Root>‘<!--'--></Root>
<Root>‘<!--‘--></Root>
<Root>‘<!--‘--></Root>
<Root>‘<!--‘--></Root>