Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,167 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,882 people online right now. Registration is fast and FREE... Join Now!




My program does not return the correct value or no value to F to Celci

 
Reply to this topicStart new topic

My program does not return the correct value or no value to F to Celci, Calculation issues. Input not being properly included in calculations

C-Rookie
16 Dec, 2007 - 06:54 PM
Post #1

New D.I.C Head
*

Joined: 15 Dec, 2007
Posts: 8


My Contributions
CODE
/* Fahrenheit to Celsius conversion program, Revision 5 */
/*Filename: week2-pkc.c */
/* This program prompts the user to enter a decimal Fahrenheit temperature to be converted to Celsius */
/*Ask the user to enter a faherinheit temperature to be converted to Celsius */
    #include <stdio.h>     /*Define data type*/
    #include <ctype.h>    /*Define data type*/
main()
{
    float Fahrenheit;     /*Variable to hold Fahrenheit*/
    float Celsius;        /*Variable to hold Celsius*/
    char cAnswer = '\0';         /*Variable to hold yes/no answer*/
    printf("Please enter a Faherinheit temperature to be converted to Celsius\n example 82 or 71.5\n");
    scanf("%f",&Fahrenheit); /*Get Fahrenheit variable from user input*/
        Celsius = (5.00/9.00)*(Fahrenheit - 32);  /*Perform calculation to convert fahrenheit to Celsius*/
    printf("Fahrenheit = %.2f\nCelsius = %.2f\n , Fahrenheit, Celsius"); /*Print out Fahrenheit number given and the Celsius Equivilant*/
    printf("Do you want to enter another temperature, Y or N ?");
    scanf("%c",&cAnswer); /*Get answer to enter another temperature*/
if (cAnswer=='Y') {
    printf("Please enter a Faherinheit temperature to be converted to Celsius\n example 82 or 71.5\n");
    scanf("%f",&Fahrenheit); /*Get Fahrenheit variable from user input*/
        Celsius = (Fahrenheit - 32) * (005.00/009.00);  /*Perform calculation to convert fahrenheit to Celsius*/
    printf("Fahrenheit = %.2f\nCelsius = %.2f\n , Fahrenheit, Celsius"); /*Print out Fahrenheit number given and the Celsius Equivilant*/
    }
else    {
    printf("Press enter to exit");
    getchar();
    return 0;}
}

User is offlineProfile CardPM
+Quote Post

Jayman
RE: My Program Does Not Return The Correct Value Or No Value To F To Celci
16 Dec, 2007 - 07:08 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,926



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Moved to C/C++ forum.

Please review the rules about posting in the correct forum, using code.gif tags, and providing the necessary information needed to provide you with accurate help.
User is offlineProfile CardPM
+Quote Post

ericode
RE: My Program Does Not Return The Correct Value Or No Value To F To Celci
19 Dec, 2007 - 07:23 PM
Post #3

D.I.C Head
Group Icon

Joined: 9 Dec, 2006
Posts: 89


Dream Kudos: 75
My Contributions
A couple of your printf statements have the quotation mark in the wrong spot:

CODE

printf("Fahrenheit = %.2f\nCelsius = %.2f\n , Fahrenheit, Celsius");


which should be

CODE

printf("Fahrenheit = %.2f\nCelsius = %.2f\n" , Fahrenheit, Celsius);

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 12:09AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month