anyone can help me !!

This is a discussion on anyone can help me !! within the C Programming forums, part of the General Programming Boards category; The table below shows the normal boiling points of several substances. Write a program that prompts the user for the ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    11

    anyone can help me !!

    The table below shows the normal boiling points of several substances. Write a program that prompts the user for the observed boiling point of a substance in C and identifies the substance if the observed boiling point is within 5% of the expected boiling point. If the data input is more than5% higher or lower than any of the boiling points in the table, the program should output the message substance unknown.

    Substance Normal boiling point (C)
    Water 100
    Mercury 357
    Copper 1187
    Silver 2193
    Gold 2660

    Your program should define and call a function within_x_percent that takes as parameters a reference value ref, a data value data, and a percentage value x and returns 1 meaning true if data is within x% of ref-that is (ref x% * ref) ≤ data ≤ (ref + x % * ref). Otherwise within_x_percent would return zero, meaning false. For example, the call within_x_percent(357, 323, 10) would return true, since 10% of 357 id 35.7, and 323 falls between 321.3 and 392.7.
    Follow these instructions:
    Create a text file (by any tool) name it (comp142.txt) that contains the second column of the above table.
    Let the program read from the created file the values of the variables in the first column of the above table.
    Write the function within_x_percent described above.
    Test your program using the following data
    1187 1100 10
    1187 1100 5


    thanks

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Shure. I can help you.
    What's the question ?
    Kurt

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    Shure. I can help you.
    What's the question ?
    Kurt
    how i can build this program
    thanks
    Last edited by ccccccc; 02-14-2010 at 02:32 PM.

  4. #4
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    You can build it by learning C. No one is going to code this for you - and expecting us to do so is explicitly against the forum rules you agreed to when you signed up. However, this is a very simple program, and if you just googled for a C tutorial, I think you would be able to write this program within a few hours. When you get stuck with a specific part of the program and have a specific question and some of your own work to show us, we'd be happy to help you with it.

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    11
    I do this program
    How did you see this ?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int within_x_percent(double , double, double);
    int main()
    {
    char a[10];
    int i ;
    int flag = 0;
    FILE *inp ;
    inp = fopen("data.txt","r");
    int x;
    printf("please enter the value to detrmine the material :\n");
    scanf("%d",&x);
    while(fscanf(inp,"%s%d",a,&i)!= EOF){
    if (within_x_percent(i,x,10) == 1 ){
    flag = 1 ;
    break ;
    }
    }
    if (flag == 1){
    printf("the material is %s \n",a);}
    else
    printf("the material doesn't exist\n");
    
    return 0;
    }
    
    int within_x_percent( double data,double ref, double x)
    {
    if (((ref - ( x*0.01)*ref) <= data) && ( data <= (ref + (x*0.01) * ref)))
    {
    return 1 ;
    }
    else
    return 0 ;
    }

  6. #6
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    No, you FOUND it here...liar.

  7. #7
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    If you really did write that code, you should have no problem completing the assignment. So, what's your problem? What do you expect us to tell you?

    If you really did steal someone else code in an attempt to cheat in your class and deceive us into helping you, then you are pathetic. If you took the time you've already spent avoiding doing the assignment and used it to learn C instead, you'd probably be done by now. Remember that a lot of us are professional programmers - and we have no interest in helping a dishonest, lazy and incompetent person get any kind of certification that they can program. We don't want to work with such a person.

    I'm closing this thread. Feel free to open another one when you've learnt some C, gotten some ethics, and have a real problem that we can help you with.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21