Conversion Learn programming C#

Lesson:

First contact with C# Sharp


Exercise:

Conversion


Objetive:

Create a C# program to convert Celsius degrees to Kelvin and Fahrenheit. The program will prompt the user to input the temperature in Celsius degrees, and then use the following conversion formulas:

Kelvin = Celsius + 273
Fahrenheit = Celsius x 1.8 + 32

The program will then display the equivalent temperature in both Kelvin and Fahrenheit units.


Code:

using System;
public class exercise14
{
    static void Main()
    {
        Console.Write("Enter the amount of celsius: ");
        int celsius = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Kelvin = {0}", celsius + 273);
        Console.WriteLine("Fahrenheit = {0}", celsius * 18 / 10 + 32);
    }
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.