Exemplo n.º 1
0
 public static int ValidationNull(int a)
 {
     while (a <= 0)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.Write("Start num not equally null. Try again: ");
         Console.ResetColor();
         a = MainMethods.ValidationStr(Console.ReadLine());
     }
     return(a);
 }
Exemplo n.º 2
0
 public static int CheckSimpleNumbers(int a)
 {
     while (CustomMethods.Methods.SimpleNumber(a) == false)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.Write("Number is not simple. Try again: ");
         Console.ResetColor();
         a = MainMethods.ValidationStr(Console.ReadLine());
         CustomMethods.Methods.SimpleNumber(a);
     }
     return(a);
 }
Exemplo n.º 3
0
 public static int ValidationMaxMin(int a, int b)
 {
     while (a > b || a == b)
     {
         while (a > b)
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.Write("Finish num must be greater than start num. Try again: ");
             Console.ResetColor();
             b = MainMethods.ValidationStr(Console.ReadLine());
         }
         while (a == b)
         {
             Console.ForegroundColor = ConsoleColor.Red;
             Console.Write("Finish num not equally start num. Try again: ");
             Console.ResetColor();
             b = MainMethods.ValidationStr(Console.ReadLine());
         }
     }
     return(b);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            int    a;
            int    b;
            int    num_1;
            int    num_2;
            int    index = 0;
            string str;
            string again;
            string check = "null";


            Console.WriteLine("This console application checks the multiplicity of numbers from the range you entered,\n" +
                              "depending on what you entered the requested factors.");

            do
            {
                Console.Write("\nEnter start num: ");
                str   = Console.ReadLine();
                num_1 = MainMethods.ValidationStr(str);
                num_1 = MainMethods.ValidationNull(num_1);


                Console.Write("Enter finish num: ");
                num_2 = MainMethods.ValidationStr(Console.ReadLine());
                MainMethods.ValidationMaxMin(num_1, num_2);

                int[] x = Methods.RangeOfNumbers(num_1, num_2);

                do
                {
                    Console.Write("\nEnter first prime factor: ");
                    str = Console.ReadLine();
                    a   = MainMethods.ValidationStr(str);
                    a   = MainMethods.ValidationNull(a);
                    Methods.SimpleNumber(a);
                    MainMethods.CheckSimpleNumbers(a);

                    Console.Write("Enter second prime factor: ");

                    str = Console.ReadLine();
                    b   = MainMethods.ValidationStr(str);
                    b   = MainMethods.ValidationNull(b);
                    Methods.SimpleNumber(b);
                    MainMethods.CheckSimpleNumbers(b);

                    if (a == b)
                    {
                        Console.Write("First simple num not second simple num. Try again\n");
                    }
                }while (a == b);

                for (int i = num_1; i < num_2; i++)
                {
                    if (x[index] % a == 0)
                    {
                        check = $"\nFizz {x[index]} / {a}";
                        Console.WriteLine(check);
                        if (x[index] % b == 0)
                        {
                            check = $"\nFizzBuzz {x[index]} / {a} and {b}";
                            Console.WriteLine(check);
                        }
                    }
                    if (x[index] % b == 0)
                    {
                        check = $"\nBuzz {x[index]} / {b}";
                        Console.WriteLine(check);
                    }
                    index = index + 1;
                }
                if (check == "null")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\nNo multiple");
                    Console.ResetColor();
                }
                Console.Write("\nAgain? Press Y and other key: ");
                again = Console.ReadLine();
            }while (again == "Y" || again == "y");
        }