|
I don't remember Ohm's formula, but here you have the program, took 5 minutes to make.
replace the comment in the subprogram 'calc' by the correct formulas.
code:
#include
#include
#include
#include
#include
#include
// Cyrax Creations
// [email protected]
//
// Ohm's law
int i, v, r, choice;
void input()
{
system("cls");
do
{
cout<<"\n\n";
cout<<"\t1. Calculate current\n";
cout<<"\t2. Calculate Voltage\n";
cout<<"\t3. Calculate Restistance\n\n";
cout<<"\t0. Quit\n\n\n";
cout<<"\t Enter your choice => ";
cin>>choice;
}
while ((choice < 0) && (choice > 3));
}
void calc()
{
if (choice == 1)
{
system("cls");
cout<<"\n\n\n";
cout<<"\tEnter Voltage => ";
cin>>v;
cout<<"\tEnter Resistance => ";
cin>>r;
// ENTER OHM'S FORMULA HERE
// i = formula_here, remove double slash;
cout<<"\n\n";
cout<<" Current = "<< i <<".";
cout<<"\n\n\n\n";
}
if (choice == 2)
{
system("cls");
cout<<"\n\n\n";
cout<<"\tEnter Current => ";
cin>>i;
cout<<"\tEnter Resistance => ";
cin>>r;
// ENTER OHM'S FORMULA HERE
// v = formula_here, remove double slash;
cout<<"\n\n";
cout<<" Voltage = "<< v <<".";
cout<<"\n\n\n\n";
}
if (choice == 3)
{
system("cls");
cout<<"\n\n\n";
cout<<"\tEnter Current => ";
cin>>i;
cout<<"\tEnter Voltage => ";
cin>>v;
// ENTER OHM'S FORMULA HERE
// r = formula_here, remove double slash;
cout<<"\n\n";
cout<<" Resistance = "<< r <<".";
cout<<"\n\n\n\n";
}
}
void main()
{
input();
calc();
}
greetz
Cyrax
|