Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Test1._1
- {
- class TemperatureConverter
- {
- // Converts Celsius to Fahrenheit
- public static double CelsiusToFahrenheit(double celsius)
- {
- return celsius * 9 / 5 + 32; // Linear transformation from Celsius to Fahrenheit
- }
- public static double FahrenheitToCelsius (double fahrenheit)
- {
- return (fahrenheit - 32) * 5 / 9; // Linear transformation from Fahrenheit to Celsius
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- // Test data
- double[] testCelsius = new double[] { 0, 100, -40 };
- double[] testFahrenheit = new double[] { 32, 212, -40 };
- // Test Celsius to Fahrenheit conversion
- foreach (double temp in testCelsius)
- {
- Console.WriteLine($"{temp} degrees Celsius is equal to {TemperatureConverter.CelsiusToFahrenheit(temp)} degrees Fahrenheit");
- }
- // Test Fahrenheit to Celsius conversion
- foreach (double temp in testFahrenheit)
- {
- Console.WriteLine($"{temp} degrees Fahrenheit is equal to {TemperatureConverter.FahrenheitToCelsius(temp)} degrees Celsius");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement