All Type Coding

Search Here

How to convert temperature entered by user from celcius degree to fahrenheit degree and viceversa in c#.?

using System;

class abc
{
double c,f;
public void ctof()
{
Console.WriteLine("conversion of temp from degree celcius to degree fahrenheit");
Console.WriteLine("enter temp in Celcius:");
c=Convert.ToDouble(Console.ReadLine());
f=((c*9)/5)+32;
Console.WriteLine("temp in Fahrenheit is : "+ f);
}
public void ftoc()
{
Console.WriteLine("conversion of temp from degree fahrenheit to degree celcius ");
Console.WriteLine("enter temp in fahrenheit :");
f=Convert.ToDouble(Console.ReadLine());
c=((f-32)*5)/9;
Console.WriteLine("temp in Celcius is : "+ c);
Console.ReadKey();
}
}
class conv
{
public static void Main(string []args)
{
abc a=new abc();
a.ctof();
a.ftoc();
}

}
Output :


No comments :

Post a Comment