Thread: Using switch statements and some other questions

  1. #16
    Registered User
    Join Date
    Sep 2009
    Posts
    36
    Just wanted to say thanks to everyone that helped me out on this one. I finally got it. Thanks so much!!!

  2. #17
    Registered User
    Join Date
    Sep 2009
    Posts
    36
    Okay, question.

    What if I inputted this:
    Enter a temperature: 32
    Enter 'C' for Celsius or 'F' for Fahrenheit: c
    Choose a conversion ('C' for Celsius or 'F' for Fahrenheit): c
    The temperature is: 0.0 C.

    I want the program to read The temperature is: 32 C. when I go from C to C but my program is outputting 0.0 C. Same thing when I go from F to F.

  3. #18
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    if you input the temperature as C and you display it as C why would you want it to display something different?

  4. #19
    Registered User
    Join Date
    Sep 2009
    Posts
    36
    Oh, it was instructed to do so by the instructor. But after fiddling around with it, I finally got it. Thanks again!

  5. #20
    Registered User
    Join Date
    Oct 2009
    Posts
    16
    Could someone please explain to me how to post a new message to the boards

  6. #21
    Registered User
    Join Date
    Oct 2009
    Posts
    5
    Quote Originally Posted by gnozahs View Post
    Wait, is the code you wrote above for storing the inputted number as C or F or actually converting it from C to F or F to C? I'm confused.

    This is what the program should look like:
    Enter a temperature: 32.4
    Enter 'C' for Celsius or 'F' for Fahrenheit: C
    Choose a conversion ('C' for Celsius or 'F' for Fahrenheit): F
    The temperature is: 90.3 F.

    If you've entered the temperature and then chosen it to be C, then what is the need to specify that it has to be converted into F. that is pretty obvious, right?

    The output could be in this way:
    Enter a temperature: 32.4
    Enter 'C' for Celsius or 'F' for Fahrenheit: C
    The converted temperature is: 90.3 F.

Popular pages Recent additions subscribe to a feed