TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aditya Varma Mudunuri
NA
58
104.6k
Conversion of Temperatures is not executing perfectly
Feb 15 2012 5:22 AM
Here is the following code & getting an error in it can u please solve it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Employee
{
public static class TempConverter
{
public static double CelsiusToFahrenheit(string TempCelsius)
{
double Celsius = double.Parse(TempCelsius);
double Fahren=(Celsius*9/5)+32;
return Fahren;
}
public static double FahrenheitToCelsius(string TempFahren)
{
double Fahren = double.Parse(TempFahren);
double Celsius = (Fahren - 32) * 5 / 9;
return Celsius;
}
}
class TemperatureStatic
{
static void Main(string[] args)
{
Console.WriteLine("Select the Conversion Direction");
Console.WriteLine("1.Celsius to FahrenHeit");
Console.WriteLine("2.FahrenHeit to Celsius");
Console.Write("You selected :");
double F, C = 0;
string selection = Console.ReadLine();
switch (selection)
{
case "1":
Console.WriteLine("PLease Enter Celsius Temperature");
F = TempConverter.CelsiusToFahrenheit(Console.ReadLine());
Console.WriteLine("Temperature in FahrenHeit is {O:F2}",F); break;
case "2":
Console.WriteLine("PLease Enter FahrenHiet Temperature");
C = TempConverter.FahrenheitToCelsius(Console.ReadLine());
Console.WriteLine("Temperature in Celsius is {O:F2}",C); break;
default:
Console.WriteLine("Please Select the Convertor");break;
}
}
}
}
Reply
Answers (
1
)
How to add .mdf file to Data Connections in Server Explorer
Please find me the optimized code for this program