add class and some OOP

This commit is contained in:
2022-06-29 22:24:01 +03:00
parent 3b87d0c682
commit fa0034a6a8
10 changed files with 161 additions and 94 deletions
+72
View File
@@ -0,0 +1,72 @@
namespace pr
{
class HomeWork
{
public void First_task()
{
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
if (a > b)
Console.WriteLine("Max is: " + a);
else
Console.WriteLine("Max is: " + b);
}
public void Second_task()
{
int max;
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Input third number: ");
int c = Convert.ToInt32(Console.ReadLine());
/// use standart System.Math
// Console.WriteLine("Max is: " + Math.Max(a, Math.Max(b, c)));
max = b > a ? b : a;
max = max > c ? max : c;
Console.WriteLine("Max is: " + max);
}
public void Third_task()
{
Console.Write("Input number for check even: ");
int inputNumber = Convert.ToInt32(Console.ReadLine());
if (inputNumber % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Not even");
}
public void Foth_task()
{
int current = 1;
Console.Write("Input number: ");
int numberTask4 = Convert.ToInt32(Console.ReadLine());
while (current <= numberTask4)
{
if (current % 2 == 0)
Console.WriteLine(current);
current++;
}
}
}
}