-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCelsius to F & Fahrenheit to C
44 lines (35 loc) · 1.22 KB
/
Celsius to F & Fahrenheit to C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*Created by Aamer Saleem Mohammed*/
using System;
namespace Fahrenheit_to_C_and_C_to_F
{
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Enter 1: Celsius to Fahreneheit\nEnter 2: Fahranheit to Celsius\n");
int cf = Convert.ToUInt16(Console.ReadLine());
// Converting Celsius to Fahrenheit
if (cf == 1)
{
Console.WriteLine("Enter temperature in Celsius: ");
double Celsius = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Temperature in Fahrenheit is: " + (Celsius * 1.8 + 32) + " F");
}
// Converting Fahrenheit to Celsius
else
{
Console.WriteLine("Enter temperature in Fahrenheit: ");
double Fahrenheit = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Temperature in Celsius is: " + (Fahrenheit - 32) / 1.8 + "C");
}
Console.ReadLine();
}
catch (Exception e)
{
//
}
}
}
}