Oehms Calculator
// Oehms.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
using namespace std;
class OhmsLaw
{
public:
void setV();
void setC();
void setR();
private:
float V, C, R;
};
void OhmsLaw::setV()
{
cout <<"What is the current\n";
cin >> C;
cout << "What is the resistance\n";
cin >> R;
V = C * R;
cout << "The voltage is " << V << endl;
}
void OhmsLaw::setC()
{
cout << "What is the voltage\n";
cin >> V;
cout << "What is the resistance\n";
cin >> R;
C = V / R;
cout << "The Current is " << C << endl;
}
void OhmsLaw::setR()
{
cout << "What is the voltage\n";
cin >> V;
cout <<"What is the current\n";
cin >> C;
R = V / C;
cout << "The resistance is " << R << endl;
}
int main()
{
jon:
OhmsLaw ohms;
int choice;
cout << "-------Ohms Law-------\n";
cout << "1. Solve for voltage\n";
cout << "2. Solve for current\n";
cout << "3. Solve for resistance\n";
cout << "------------------------\n";
cin >> choice;
switch(choice)
{
case 1:
cout << "You have picked Voltage\n";
ohms.setV();
break;
case 2:
cout << "You have picked Current\n";
ohms.setC();
break;
case 3:
cout << "You have picked Resistance\n";
ohms.setR();
break;
}
if choice != int choice
cout << "pick an integer";
end if
goto jon
int x;
cin >> x;
return 0;
}