0
using System;      

class TemperatureConverter
{
    static void Main()
    {    
        //Tc = temperature in degrees Celsius
        //Tf = temperature in degrees Fahrenheit   

        Console.WriteLine("What is the Celsius Temperature: ");
        int Tf = int.Parse(Console.ReadLine());

        float Tc;

        Console.WriteLine("Temperature in Celsius is  {0} ", Tc = (5 / 9) * (Tf - 32));    
    }
}

I guess i dont i have a long way to go into the whole thing - can't figure out what did i mess up.

DIF
  • 2,470
  • 6
  • 35
  • 49

1 Answers1

4

5 / 9 performs and integer division. use d literal on one of the operands so it will perform double precision division and give you the expected result.

Tc = (5d / 9) * (Tf - 32)
Chris Hinton
  • 866
  • 5
  • 15
Selman Genç
  • 100,147
  • 13
  • 119
  • 184