Thread: Completely Clueless!!

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    3

    Post Completely Clueless!!

    Hello, I have this program to do and I'm completely clueless on how to get started. Any suggestions will be greatly appreciated.

    Write a program to convert Celsius to Fahrenheit or Fahrenheit to Celsius depending on the user’s choice.
    a. Use main( ) as the driver function. main( ) should allow the user to run the program as many times as desired.
    b. Write the function getConvertChoice( ) to prompt the user for the desired conversion:
    1. Celsius to Fahrenheit
    2. Fahrenheit to Celsius.
    Return this value back to main( ).
    c. Write the function getTemperature( ) to prompt the user for the temperature in degrees to be converted.
    d. Depending on the user’s conversion choice: 1) call the function convertToFahren( ), if the user chose to convert from Celsius to Fahrenheit, or 2) call the function convertToCelsius( ) if the user chose to convert from Fahrenheit to Celsius. The formulas are:
    Fahrenheit = (9.0/5.0) * Celsius + 32.0
    Celsius = (5.0/9.0) * (Fahrenheit – 32.0)
    e. Write the function displayConversion( ) to display the original temperature entered and the converted temperature with appropriate messages. Display the values to a tenth of a decimal.

  2. #2
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    hello, first of all you need to know the formula that can converts these two to one another!
    a formula that converts Celsius to Fahrenheit is "F=(9.5/5.5)*c+32 where C is temp in Celsius !
    about main. it is announcing that you should make a console application. where your duty is to place two other functions inside that and also respectively the other needed function , the program is rather easy to implement , look at the sample code i wrote . dont copy it ~ it may have errors , cuz i didnt pay a carful attention to it ! and just wanted to show you the steps !
    so Good luck
    Code:
    #include <@#>
    
    void convertToCelsius(double);
    void convertToFahren(double);
    int getConvertChoice( int);
    double getTemperature(int );
    
    int main()
    {
        int x;
        
       getConvertChoice(x);
       getTemperature(x);
    
    return 0;
    }
    
    double getTemperature(int choice)
    {
          if (choice ==1)
           convertToFahren( );
        else 
          convertToCelsius( );
    }
    int getConvertChoice(int x)
    {
    }
    void convertToFahren(double z )
    {
         ~
         ~
         ~
        cout<<z<<endl;
    }
    convertToCelsius(w )
    {
         ~
         ~
         ~
         cout<<w<<endl;
    }
    Last edited by Masterx; 10-29-2008 at 06:30 AM.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Not sure I understand.....

  4. #4
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    what is it that you dont understand? and where?

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Freeport, IL
    Posts
    32
    Seems like he wants his homework done for him, that is a basic beginning homework assignment.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If you are going to post code, at least indent it properly.
    And do not just hand out code or answers to the newbies. It will teach them nothing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    Quote Originally Posted by Masterx View Post
    hello, first of all you need to know the formula that can converts these two to one another!
    a formula that converts Celsius to Fahrenheit is "F=(9.5/5.5)*c+32 where C is temp in Celsius !
    about main. it is announcing that you should make a console application. where your duty is to place two other functions inside that and also respectively the other needed function , the program is rather easy to implement , look at the sample code i wrote . dont copy it ~ it may have errors , cuz i didnt pay a carful attention to it ! and just wanted to show you the steps !
    so Good luck
    Code:
    #include <@#>
    
    void convertToCelsius(double);
    void convertToFahren(double);
    int getConvertChoice( int);
    double getTemperature(int );
    
    int main()
    {
        int x;
        
       getConvertChoice(x);
       getTemperature(x);
    
    return 0;
    }
    
    double getTemperature(int choice)
    {
          if (choice ==1)
           convertToFahren( );
        else 
          convertToCelsius( );
    }
    int getConvertChoice(int x)
    {
    }
    void convertToFahren(double z )
    {
         ~
         ~
         ~
        cout<<z<<endl;
    }
    convertToCelsius(w )
    {
         ~
         ~
         ~
         cout<<w<<endl;
    }
    Yeah... That code formatting is just ridiculous and it's even worse to give it to noobs.

  8. #8
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by Elysia View Post
    If you are going to post code, at least indent it properly.
    And do not just hand out code or answers to the newbies. It will teach them nothing.
    just tried to show him the outline !
    and help !
    if any thing was/is wrong i'll appriciate your comment .
    (is it now indented properly?!)

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Masterx View Post
    just tried to show him the outline !
    and help !
    Yes, and it gives away a huge amount of information that you are merely giving away that they themselves should be able to do.
    The best thing would be for the OP to do what code he/she can, consult the books and ask questions if there is something in there that he/she does not understand, which would be where we come in.

    (is it now indented properly?!)
    Is it indented? Yes.
    Properly? No.

    This is an example of how properly indented code should look like:
    Code:
    #include <@#>
    
    void convertToCelsius(double);
    void convertToFahren(double);
    int getConvertChoice( int);
    double getTemperature(int );
    
    int main()
    {
    	int x;
    
    	getConvertChoice(x);
    	getTemperature(x);
    
    	return 0;
    }
    
    double getTemperature(int choice)
    {
    	if (choice ==1)
    		convertToFahren( );
    	else 
    		convertToCelsius( );
    }
    int getConvertChoice(int x)
    {
    }
    void convertToFahren(double z )
    {
    	~
    	~
    	~
    	cout<<z<<endl;
    }
    convertToCelsius(w )
    {
    	~
    	~
    	~
    	cout<<w<<endl;
    }
    And also a word of advice: do not strip the names of the parameters in the function prototypes. Just... do not.
    And convertToCelcius also lacks return type and parameter type, so it is even more bad.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    And a sidenote, your function names "convertToCelsius", "getTemperature" and so on, kind of imply that the functions return the value passed to it (get/set), as celsius/fahrenheit, however they only seem to convert and then print them to stdout, never really returning anything to main(). Perhaps a more fitting name would be printAsCelsius or outputCelsius etc, might aswell use proper names, makes the coder easier to follow and easier for others to use.

    And finally, look at the main() function you provided, x is never initialized, the value is never changed (regardless of what getConvertChoice is supposed to do), so the value that is passed to getTemperature is some random gibberish, which will obviously yield very incorrect output.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  11. #11
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    This is so basic a program that if jap2010 had done a google search he/she would find the code.

    If this homework is giving them problems then they are either extremely lazy and never opened their book, or retarded. I would have loved to be able to use the internet when I was in beginning programming classes. Unfortunately Al Gore hadn't invented it yet.
    Last edited by DaveH; 10-29-2008 at 07:36 AM.

  12. #12
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    Quote Originally Posted by Elysia View Post
    Yes, and it gives away a huge amount of information that you are merely giving away that they themselves should be able to do.
    The best thing would be for the OP to do what code he/she can, consult the books and ask questions if there is something in there that he/she does not understand, which would be where we come in.



    Is it indented? Yes.
    Properly? No.

    This is an example of how properly indented code should look like:
    Code:
    #include <@#>
    
    void convertToCelsius(double);
    void convertToFahren(double);
    int getConvertChoice( int);
    double getTemperature(int );
    
    int main()
    {
        int x;
    
        getConvertChoice(x);
        getTemperature(x);
    
        return 0;
    }
    
    double getTemperature(int choice)
    {
        if (choice ==1)
            convertToFahren( );
        else 
            convertToCelsius( );
    }
    int getConvertChoice(int x)
    {
    }
    void convertToFahren(double z )
    {
        ~
        ~
        ~
        cout<<z<<endl;
    }
    convertToCelsius(w )
    {
        ~
        ~
        ~
        cout<<w<<endl;
    }
    And also a word of advice: do not strip the names of the parameters in the function prototypes. Just... do not.
    And convertToCelcius also lacks return type and parameter type, so it is even more bad.
    many tanx Dear Elysia. i will definitely remember that.(indention )
    and about the functions, i really didnt pay a careful attention , as i mentioned explicitly before , i just wanted to show him/her how it could be in a terms of function!.thats why i missed couple of stuff !
    (and because i was using notepad to write those codes, and meanwhile forgot about the Tab to indent properly , thats what it looks like now!

    i wont correct the problems(or should i correct it? i dont know?) , because if i do this would spoil the fact that hes is learning.!and by doing such a thing he/she wont learn it though!

    Quote Originally Posted by Neo1 View Post
    And a sidenote, your function names "convertToCelsius", "getTemperature" and so on, kind of imply that the functions return the value passed to it (get/set), as celsius/fahrenheit, however they only seem to convert and then print them to stdout, never really returning anything to main(). Perhaps a more fitting name would be printAsCelsius or outputCelsius etc, might aswell use proper names, makes the coder easier to follow and easier for others to use.

    And finally, look at the main() function you provided, x is never initialized, the value is never changed (regardless of what getConvertChoice is supposed to do), so the value that is passed to getTemperature is some random gibberish, which will obviously yield very incorrect output.
    many tanx darling, i said the reasons above! and by the way YOu ve just made a point here that i didnt paid attention before , tanx for the tip !

    Quote Originally Posted by DaveH View Post
    This is so basic a program that if jap2010 had done a google search he/she would find the code.

    If this homework is giving them problems then they are either extremely lazy and never opened their book, or retarded. I would have loved to be able to use the internet when I was in beginning programming classes. Unfortunately Al Gore hadn't invented it yet.
    people have different reasons for their question , we shouldnt make fun of them cuz they dont understand sth because of sth!! its just ridicules ! sorry but i think the term retarded is not proper ! to be called to any one specially here!
    ( but i go along with you in terms of searching before asking)!


    I really appreciate you guys and your great tips . tanx , hope these things help newbies like me flourish faster !

  13. #13
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Okay, lets change it to mentally handicapped.

    Seriously, if they have read and studied their book or did a quick internet search, and they still have no clue at all on how to start, then they have something wrong with their brain.

  14. #14
    Registered User
    Join Date
    Oct 2009
    Posts
    1
    many thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open source my OIOIC, a completely new object-oriented mechanism for the C.
    By pervise.zhao in forum Projects and Job Recruitment
    Replies: 23
    Last Post: 03-17-2010, 07:14 PM
  2. Serial port: How to know when data has been completely sent
    By arjunajay in forum Windows Programming
    Replies: 8
    Last Post: 03-25-2009, 08:18 AM
  3. Problem with deleting completely blank lines
    By dnguyen1022 in forum C Programming
    Replies: 3
    Last Post: 12-07-2008, 11:51 AM
  4. completely stuck understanding how to use time.h
    By pastitprogram in forum C++ Programming
    Replies: 11
    Last Post: 04-04-2008, 10:11 AM
  5. Completely modular motherboards?
    By SMurf in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 02-23-2003, 12:56 PM

Tags for this Thread