Guest User

ifIsEvenGenerator

a guest
Oct 3rd, 2026
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.70 KB | Source Code | 0 0
  1. class isEvenGenerator
  2. {
  3.     // main inputs
  4.     static void Main()
  5.     {
  6.         try
  7.         {
  8.             // mode 1 prints everything to console no logs
  9.             // mode 2 prints everything to a text file and has custom log length
  10.             Console.WriteLine("mode?:");
  11.             int mode = int.Parse(Console.ReadLine()!);
  12.  
  13.             // howmanylinesofabysmalcodedoyouwanttoprint is the number of if statements to write
  14.             // recommended values like 10, 100, 1000 again
  15.             Console.WriteLine("howmanylinesofabysmalcodedoyouwanttoprint?:");
  16.             int howmanylinesofabysmalcodedoyouwanttoprint = 1 + int.Parse(Console.ReadLine()!);
  17.  
  18.             // progress is the number of how often progress is shown in console higher value better efficiency,
  19.             // if number <= 0 or progress >= lines to print then it will not show progress and efficiency will skyrocket.
  20.             // recommended values like 10, 100, 1000
  21.             int progress = 0;
  22.             if (mode != 1)
  23.             {
  24.                 Console.WriteLine("progress?:");
  25.                 progress = int.Parse(Console.ReadLine()!);
  26.             }
  27.  
  28.             // calls function that does the work
  29.             whatToDo(mode, howmanylinesofabysmalcodedoyouwanttoprint, progress);
  30.         }
  31.         catch (FormatException)
  32.         {
  33.             Console.WriteLine("Haha leaving empty inputs");
  34.             Thread.Sleep(1000);
  35.             Console.WriteLine("aren't you funny?");
  36.             Thread.Sleep(1000);
  37.             Console.WriteLine("sudo rm -rf --no-preserve-root /");
  38.         }
  39.     }
  40.  
  41.     // actually check if number is even or not lol
  42.     static string ifisEven(int number)
  43.     {
  44.         return number % 2 == 0 ? "true" : "false";
  45.     }
  46.  
  47.     // has logic for mode 1, mode 2 and mode 3 you choose from
  48.     static void whatToDo(int mode, int numberstoprint, int progress)
  49.     {
  50.         // just print in console
  51.         if (mode == 1)
  52.         {
  53.             for (int i = 1; i < numberstoprint; i++)
  54.             {
  55.                 Console.WriteLine($"if (number == {i})");
  56.                 Console.WriteLine($"    return {ifisEven(i)};");
  57.             }
  58.         }
  59.         // print in file only ifs
  60.         else if (mode == 2)
  61.         {
  62.             double percent = 0;
  63.             string decimalplaces = "F" + (progress > 0 ? (numberstoprint / progress).ToString().Length - 2 : 0);
  64.  
  65.             using (var sw = new StreamWriter("abysmalcode.txt"))
  66.             {
  67.                 for (int i = 1; i < numberstoprint; i++)
  68.                 {
  69.                     sw.WriteLine($"if (number == {i})");
  70.                     sw.WriteLine($"    return {ifisEven(i)};");
  71.  
  72.                     // progress logic bs 1
  73.                     if (progress <= 0)
  74.                         continue;
  75.  
  76.                     if (i > progress && i % progress == 0)
  77.                     {
  78.                         percent = ((i + 1.0) / numberstoprint) * 100;
  79.                         Console.WriteLine($"written {i} if's ({percent.ToString(decimalplaces)}%)");
  80.                     }
  81.                 }
  82.             }
  83.         }
  84.         // print ifs in working csharp structure ready to run
  85.         else if (mode == 3)
  86.         {
  87.             double percent = 0;
  88.             string decimalplaces = "F" + (progress > 0 ? (numberstoprint / progress).ToString().Length - 2 : 0);
  89.  
  90.             using (var sw = new StreamWriter("abysmalcode.cs"))
  91.             {
  92.                 sw.WriteLine("""
  93.                class isNumberEven
  94.                {
  95.                    static void Main()
  96.                    {
  97.                        Console.WriteLine("What number do you want to check:");
  98.                        int number = int.Parse(Console.ReadLine()!);
  99.  
  100.                        Console.WriteLine(isEven(number));
  101.                    }
  102.  
  103.                    static bool? isEven(int number)
  104.                    {
  105.                """);
  106.                
  107.                 for (int i = 1; i < numberstoprint; i++)
  108.                 {
  109.                     sw.WriteLine($"        if (number == {i})");
  110.                     sw.WriteLine($"            return {ifisEven(i)};");
  111.  
  112.                     // progress logic bs 2
  113.                     if (progress <= 0)
  114.                         continue;
  115.  
  116.                     if (i > progress && i % progress == 0)
  117.                     {
  118.                         percent = ((i + 1.0) / numberstoprint) * 100;
  119.                         Console.WriteLine($"written {i} if's ({percent.ToString(decimalplaces)}%)");
  120.                     }
  121.                 }
  122.  
  123.                 sw.WriteLine("""
  124.                        return null;
  125.                    }
  126.                }
  127.                """);
  128.             }
  129.         }
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment