+ Reply to Thread
Results 1 to 5 of 5

Thread: C -help

  1. #1
    Member
    Join Date
    Jan 2000
    Posts
    57

    C -help

    Anyone know how to do this problem :
    The purpose of this project is to develop a C program which will automatically calculate the value of either resistance, current or voltage based on the other two given values in the formula

    Voltage = Resistance * Current ( Ohm¡¯s Law )

    That is, if you enter values for resistance and current, the program will automatically calculate the corresponding voltage based the formula above. Similarly, if you enter values of voltage and current, the program will automatically calculate the corresponding resistance value based on the Ohm¡¯s Law.

    The program can run repeatedly to calculate many sets of inputs and corresponding results until you terminate the program by entering 0 at the prompt for input.

    2 Inputs to the Program

    The user is presented with a menu such as below to indicate the type (resistance, current or voltage) of data for the input.

    *************************************************
    * *
    * Menu *
    * *
    * Type 1 to enter Resistance value *
    * Type 2 to enter Current value *
    * Type 3 to enter Voltage value *
    * Type 0 to exit the program *
    * *
    *************************************************

    If any number other than 0 to 3, inclusive, were entered, the system will continue to prompt for the inputs with the above menu. The data entered are of floating point type.

    Upon entering the first value, say Resistance, the menu will appear again to prompt the user for the second value. Assuming that the user chooses to enter the voltage value this time, the program will then determine that the Current is to be calculated and it is then calculated accordingly.

    What happens when both consecutive inputs are of the same type (may be of different values)? The program will assume the latter input as the valid value for computation of result.


    3 Outputs of the Program

    When any two variables of the Ohm¡¯s Law Equation is calculated, the third parameter can be calculated and the overall result is displayed in the manner (correct to 2 decimal points) below:

    By Ohm¡¯s Law,

    Resistance = xxx.xx Ohms
    Current = xxx.xx Amperes
    Voltage = xxxxxx.xx Volts

    By hitting on any key, the input menu as given in the Inputs to the Program above will be displayed again. The user can then enter another pair of values (any two parameters of the Ohm¡¯s Law) for computation of the third parameter of the Ohm¡¯s Law.

  2. #2
    Member strangerstill's Avatar
    Join Date
    Sep 2001
    Location
    Oxford
    Posts
    203
    What I recommend you do is get a big pad of A4, and draw a flowchart, hand-testing it once you have it finished.

    Then write the thing.

    Come back if you run into trouble.

  3. #3
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    Yes, I do...

    when I was young, we, did our own homework.

    BUT, my dad had to walk to school, uphill boff ways!

    You have the reqs, what is stopping you?
    ==========================
    //this from memory, so check sintacks
    int age;
    printf("how old are you");
    scanf("%d", &age);
    printf("You are (%d) years old.", age);
    Last edited by qball; 09-24-2001 at 08:07 PM.

  4. #4
    Member emcron's Avatar
    Join Date
    Mar 1999
    Location
    Universe
    Posts
    450
    I have to agree with these guys, this program is very simple. You have the equations, just put them in your program. What it sounds like is that you have no idea on how to get started. So go read the book and look at the examples, or look for the many example that you can find on the internet.
    The best defense against terrorism is not war, but justice.

  5. #5
    Member vass0922's Avatar
    Join Date
    Feb 2000
    Location
    Centreville, VA US
    Posts
    385
    Just to help ya get started.

    You would want a case statement to enter the values
    Maybe an if then else of.. as well

    If voltage = empty (or 0 whatever)
    then do this formula
    if current = empty
    then do this formula
    else
    do this formula


    Not gonna show ya the code, the code is fairly simple if you know the language :P LOL

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts







New Security Features Planned for Firefox 4
Another Laptop Theft Exposes 21K Patients' Data
Oracle Hits to Road to Pitch Data Center Plans
Microsoft Preps Array of Windows Patches
Microsoft Nears IE9 Beta With Final Preview
Simplified Analytics Improve CRM, BI Tools
Android Passes RIM as Top Mobile OS in 2Q
VMware Updates Hyperic System Management
File Monitoring Key to Enterprise Security
LinkedIn Snaps Up SaaS Player mSpoke