THE PIECE OF CODING THAT I HAVE HIGHLIGHTED BELOW KEEPS SHOWING ERRORS, WHY? CAN YOU FIX IT
class Program {
public void Menu() //Menu function to print menu { Console.WriteLine("Enter P-to print menu\nEnter C-to convert from Celsius c.\nEnter F-to convert from Fahrenheit"); //printing the menu } public void CelsiusToFahrenheit() //function to convert celcius to fahrenheit { int cel; double toFah; Console.WriteLine("Enter a number to convert from celsius to Fahrenheit"); cel = Convert.ToInt32(Console.ReadLine()); toFah = (double)cel * 9 / 5 + 32; //converting to fahrenheit Console.WriteLine("After converting to Fahrenheit = " + toFah);//printing the fahrenheit value
} public void FahrenheitToCelsius()//this is the function to convert fahrenheit to celsius { int fah;//the variable to store fahrenheit value double toCel; Console.WriteLine("Enter a number to convert from Fahrenheit to celsius"); fah = Convert.ToInt32(Console.ReadLine());//taking fahrenheit input from user toCel = (double)(fah - 32) * 5 / 9;//converting to fahrenhiet Console.WriteLine("After converting to Celsius = " + toCel);
} public static void Main(string[] args) { Temperature tp = new Temperature(); char ch; int cel; int fah; double toCel; double toFah; Console.WriteLine("Enter P-to print menu\nEnter C-to convert from Celsius c.\nEnter F-to convert from Fahrenheit"); ch = Console.ReadLine()[0]; if (ch == 'P') { tp.Menu(); } else if (ch == 'C') { tp.CelsiusToFahrenheit(); } else if (ch == 'F') { tp.FahrenheitToCelsius(); }
} }
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here