You really should consider another course to take... That has to be the easiest thing they could ask you to do
...set up a loop with the menu structure asking for the values of at least two variables of IVR (IV, IR, VR) - exit when say a 'q'uit key is in input or whatever...
...and then from there jump to the calculation function(s) and output your result with the variables input... I guess you could use cases ...
___________________
"In a world of illusion you only see what you feel"
Nov-14-2002 16:01
tranceaholic
chus & Ceballos addict
Registered: Mar 2002
Location: behind the decks
yeah it is a very simple progy..ask the user to make a choice
cin that choice...do a while loop to calulate the value of v=ir until the user cin's a q to quit for example...
Nov-14-2002 16:09
PSi
Come to Daddy
Registered: Feb 2001
Location: Fort McMurray, AB
pm tranceaholic.
yeah i see the overall kist of it, its just the syntax that i cant get over.
later
PSi
Nov-14-2002 16:15
Cyrax
Supreme tranceaddict
Registered: May 2001
Location: Belgium
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
Nov-14-2002 22:10
tranceaholic
chus & Ceballos addict
Registered: Mar 2002
Location: behind the decks
by the way the formula is V=IR
Nov-14-2002 23:06
<tuss>
trance plant.
Registered: Sep 2001
Location: calgary canada
ohms law
V=I/R
I=V*R
R=I/V
I think
___________________
Nov-15-2002 00:07
reveal
always in the mix
Registered: May 2001
Location: Sweden
U = RI
___________________
man with no sig
Nov-15-2002 01:02
tranceaholic
chus & Ceballos addict
Registered: Mar 2002
Location: behind the decks
it is V=IR and I=V/R...v is the voltage or potensial difference and I is the current and R is the resistance...ohms law satets that the voltage is directly proportional to the current intensity and the resistance hence V=IR
Nov-15-2002 01:04
Photo_bot_2k1
Photo_bot_2k5 ;D
Registered: Jan 2002
Location: Berkeley,CA
i agree with swamper
and cyrax u like made it mroe cmoplicated than it acctualyl is :P
___________________
Nov-15-2002 01:42
SmellsExcellent
fuckedupandconfused
Registered: Dec 2001
Location: Shangri-La
quote:
Originally posted by Photo_bot_2k1
i agree with swamper
and cyrax u like made it mroe cmoplicated than it acctualyl is :P
i second both of those...
all you need is a quick menu guy, the inputs, and functions to calculate the different things.. sould be less than 40 lines of code or so....