Ok so after modeling after another application Im modifying a previous console app which converts Celsius

temp (with user input) to Fahrenheit. Visual Studio has annoying habits to give errors on variables that "haven't been declared yet". Im looking at this and wondering why the heck is it complaining. I have the identifier's all correct and took into account the syntax errors that could be done.
i think for the first line "const float" Im wondering whether to just place "Celsius * 9/5 +32 " instead of just "c" since it doesn't like that.

const float CELSIUS_TO_FAHRENHEIT =   * 9/5 + 32; 

            double celsius;

            celsiusTemp = GetCelsiusTemp();
            celsius = CalculateCelsius(celsiusTemp, CELSIUS_TO_FAHRENHEIT);

        public static void DisplayInstructions()
            Console.WriteLine("Welcome to the Celsius to Fahrenheit Converter!");


        public static double GetCelsiusTemp()
            string inValue;
            int celsius;

            Console.WriteLine("\n\nPlease Enter the Celsius value you wish to convert");
            inValue = Console.ReadLine();
            celsius = int.Parse(inValue);
            return celsius;

        public static int CalculateCelsius(int celsius, int CELSIUS_TO_FAHRENHEIT)
            return celsius * (9/5 + 32);

        public static void DisplayResults(int celsius)
            Console.WriteLine("Temperture in Fahrenheit");

Thanks for the help

Recommended Answers

All 5 Replies

1) Remove the * typo before the numbers: const float CELSIUS_TO_FAHRENHEIT = *(9/5+32);
2) The function should be CalculateCelsius(double, double) not (int,int).

edit: Also you never declared celsiusTemp.

double celsius, celsiusTemp;

What you are missing is in line 29, this part celsius * (9/5 + 32). Since all those values are integers, it's going to do integer math on them. What this means to you is that 9/5 = 1. The other problem with that line is that you put () in there, remove them otherwise it will multiply celsius by 33 each time (or 33.8 once you fix the int/double problem).

The problem is with the first line, a '*' would actually mean a pointer to the compiler. @nkm123 : placing * before the numbers would still not work. the reason being pointer understanding by compiler.
the reason i guess you are using * is to directly manipulate the multiplication on line 29, right..? if so, please remove it, you can use
return celsius * CELSIUS_TO_FAHRENHEIT; directly.

interesting I will look into that, I finished the project it took a lot of tinkering around and rearranging my method statements around and moving in and out of the method, class, etc. But again you guys gave me the help and direction needed in order to do that!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.