Adding project with task finished
This commit is contained in:
75
Program.cs
Normal file
75
Program.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Text;
|
||||
|
||||
namespace opg1
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine($"AddAndMultiply: {AddAndMultiply(2, 4, 5)}");
|
||||
Console.WriteLine($"CToF(0): {CtoF(0)}");
|
||||
Console.WriteLine($"CToF(100): {CtoF(100)}");
|
||||
Console.WriteLine($"CToF(-300): {CtoF(-300)}");
|
||||
Console.WriteLine($"ElementaryOperations(3, 8): {string.Join(", ", ElementaryOperations(3, 8))}");
|
||||
Console.WriteLine($"IsResultTheSame(2+2, 2*2): {IsResultTheSame(2 + 2, 2 * 2)}");
|
||||
Console.WriteLine($"IsResultTheSame(9/3, 16-1): {IsResultTheSame(9 / 3, 16 - 1)}");
|
||||
Console.WriteLine($"ModuloOperations(8, 5, 2): {ModuloOperations(8, 5, 2)}");
|
||||
Console.WriteLine($"CubeOf(2): {CubeOf(2)}");
|
||||
Console.WriteLine($"CubeOf(-5.5): {CubeOf(-5.5)}");
|
||||
Console.WriteLine($"SwapTwoNumbers(87, 45): {SwapTwoNumbers(87, 45)}");
|
||||
Console.WriteLine($"SwapTwoNumbers(-13, 2): {SwapTwoNumbers(-13, 2)}");
|
||||
}
|
||||
|
||||
static int AddAndMultiply(int a, int b, int c)
|
||||
{
|
||||
return (a + b) * c;
|
||||
}
|
||||
|
||||
static string CtoF(int celcius)
|
||||
{
|
||||
if (celcius <= -271.15)
|
||||
return "Temperature below absolute zero!";
|
||||
|
||||
double fahrenheit = (celcius * 1.8) + 32;
|
||||
|
||||
return $"T = {fahrenheit}F";
|
||||
}
|
||||
|
||||
static List<double> ElementaryOperations(double a, double b)
|
||||
{
|
||||
List<double> retval = [a + b, a - b, a * b];
|
||||
if (a > 0 && b > 0)
|
||||
retval.Add(a / b);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static bool IsResultTheSame(double a, double b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static int ModuloOperations(int a, int b, int c)
|
||||
{
|
||||
return (a % b) / c;
|
||||
}
|
||||
|
||||
static double CubeOf(double a)
|
||||
{
|
||||
return a * a * a;
|
||||
}
|
||||
|
||||
static string SwapTwoNumbers(int a, int b)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.Append($"Before: a = {a}, b = {b}; ");
|
||||
|
||||
(a, b) = (b, a);
|
||||
|
||||
sb.Append($"After: a = {a}, b = {b}");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user