return to tranceaddict TranceAddict Forums Archive > Main Forums > Chill Out Room

 
Ohm's law......C++ PROG.....die c++ die!
View this Thread in Original format
PSi
could you guys help me do this program, its simple but i just dont know how the hell to do it. Your help would be much appreciated.

http://www.cs.ncl.ac.uk/old/modules...csc601/ohm.html


many many thanks,

later
PSi
Swamper
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 ...
tranceaholic
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...
PSi
pm tranceaholic.


yeah i see the overall kist of it, its just the syntax that i cant get over.


later
PSi
Cyrax
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 // cyrax_000@hotmail.com // // 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
tranceaholic
by the way the formula is V=IR
<tuss>
ohms law
V=I/R
I=V*R
R=I/V

I think
reveal
U = RI
tranceaholic
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 ;)
Photo_bot_2k1
i agree with swamper
and cyrax u like made it mroe cmoplicated than it acctualyl is :P

SmellsExcellent
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....

-Marc
CLICK TO RETURN TO TOP OF PAGE
 
Privacy Statement