using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class NumberFilterTest {
    public static void Main(string[] args) {
        int result = -1;
        if (Test1() && Test2() && Test3()) {
            result = 0;
        }
        Console.WriteLine("All tests passed: " + (result == 0));
        Environment.Exit(result);
    }

    private static bool Test1() {
        var input = new List<int>{15, 33, 1422, 1};
        var expected = new List<int>{1, 15, 33};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }

    private static bool Test2() {
        var input = new List<int>{152, 323, 1422, 10};
        var expected = new List<int>{};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }

    private static bool Test3() {
        var input = new List<int>{111, 113, 115, 117};
        var expected = new List<int>{111, 113, 115, 117};
        var output = NumberFilter.FilterOddDigitNumbers(input);
        return output.SequenceEqual(expected);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class NumberFilter {
    public static List<int> FilterOddDigitNumbers(List<int> numbers) {
        return numbers.Where(number => number.ToString().All(c => "13579".Contains(c)))
                      .OrderBy(number => number)
                      .ToList();
    }
    public static void Check() {
        var test1 = new List<int>{15, 33, 1422, 1};
        var expected1 = new List<int>{1, 15, 33};
        Debug.Assert(FilterOddDigitNumbers(test1).SequenceEqual(expected1));
        var test2 = new List<int>{152, 323, 1422, 10};
        var expected2 = new List<int>{};
        Debug.Assert(FilterOddDigitNumbers(test2).SequenceEqual(expected2));
        Console.WriteLine("All tests passed successfully.");
    }

}

Imagine you're working on a software that processes numerical data. You've encountered a specific requirement: from a given list of positive integers, you need to filter out and return a new list containing only those numbers that do not have any even digits. Additionally, the numbers in the resulting list should be sorted in ascending order. How would you go about implementing a function in C# to meet this requirement?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class NumberFilter
{
    public static List<int> FilterOddDigitNumbers(List<int> numbers) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class UniqueFilterTest
{
    public static int Main()
    {
        bool allTestsPass = true;

        // Test Case 1
        List<int> testList1 = new List<int> { 1, 2, 3, 2, 4 };
        List<int> expected1 = new List<int> { 2, 2 };
        List<int> result1 = UniqueFilter.FilterNonUniqueNumbers(testList1);
        if (!result1.SequenceEqual(expected1))
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPass = false;
        }

        // Test Case 2
        List<int> testList2 = new List<int> { 1, 1, 1, 1, 1 };
        List<int> expected2 = new List<int> { 1, 1, 1, 1, 1 };
        List<int> result2 = UniqueFilter.FilterNonUniqueNumbers(testList2);
        if (!result2.SequenceEqual(expected2))
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPass = false;
        }

        // Test Case 3
        List<int> testList3 = new List<int> { 1, 2, 3, 4, 5 };
        List<int> expected3 = new List<int> { };
        List<int> result3 = UniqueFilter.FilterNonUniqueNumbers(testList3);
        if (!result3.SequenceEqual(expected3))
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPass = false;
        }

        // Test Case 4
        List<int> testList4 = new List<int> { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1 };
        List<int> expected4 = new List<int> { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1 };
        List<int> result4 = UniqueFilter.FilterNonUniqueNumbers(testList4);
        if (!result4.SequenceEqual(expected4))
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPass = false;
        }

        // Test Case 5
        List<int> testList5 = new List<int> { 10, 20, 30, 20, 10, 40 };
        List<int> expected5 = new List<int> { 10, 20, 20, 10 };
        List<int> result5 = UniqueFilter.FilterNonUniqueNumbers(testList5);
        if (!result5.SequenceEqual(expected5))
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPass = false;
        }

        if (allTestsPass)
        {
            Console.WriteLine("All test cases passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some test cases failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class UniqueFilter
{
    public static List<int> FilterNonUniqueNumbers(List<int> numbers)
    {
        var numberCounts = numbers.GroupBy(n => n)
                                  .ToDictionary(group => group.Key, group => group.Count());
        return numbers.Where(n => numberCounts[n] > 1).ToList();
    }
}
class Program
{
    ;
        List<int> filteredList = UniqueFilter.FilterNonUniqueNumbers(testList);
        Console.WriteLine("Filtered List: " + string.Join(", ", filteredList));
    }
}

Can you write a C# method that filters out all the numbers from a list that appear only once? The method should preserve the original order of the numbers that are not filtered out. For example, if the input list is `[1, 2, 3, 2, 4]`, the output should be `[2, 2]` because the number 2 is the only one that appears more than once.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class UniqueFilter
{
    public static List<int> FilterNonUniqueNumbers(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class RoundingAssistantTest {
    public static int Main(string[] args) {
        int result = 0;

        // Test cases
        if (RoundingAssistant.RoundDecimal("10.5") != 11) result = -1;
        if (RoundingAssistant.RoundDecimal("2.5") != 3) result = -1;
        if (RoundingAssistant.RoundDecimal("-2.5") != -3) result = -1;
        if (RoundingAssistant.RoundDecimal("10") != 10) result = -1;
        if (RoundingAssistant.RoundDecimal("-10") != -10) result = -1;

        return result;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class RoundingAssistant {
    public static int RoundDecimal(string numberString) {
        decimal number = decimal.Parse(numberString);
        decimal fractionalPart = number % 1;
        if (Math.Abs(fractionalPart) == 0.5m) {
            if (number > 0) {
                return (int)(number - fractionalPart + 1);
            } else {
                return (int)(number - fractionalPart - 1);
            }
        } else {
            return (int)Math.Round(number, MidpointRounding.AwayFromZero);
        }
    }
    public static void Check() {
        Console.WriteLine(RoundDecimal("10.5"));
        Console.WriteLine(RoundDecimal("2.5"));
        Console.WriteLine(RoundDecimal("-2.5"));
        Console.WriteLine(RoundDecimal("10"));
        Console.WriteLine(RoundDecimal("-10"));
    }
}
class Program {

}

Imagine you're working on a financial application where precision is key. You need to write a method that accurately rounds a decimal number represented as a string to the nearest whole number. However, there's a twist: if the decimal is exactly halfway between two integers, you should round it in a direction away from zero. This means, for example, 2.5 becomes 3, and -2.5 becomes -3. Can you craft a C# method that handles this rounding strategy?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class RoundingAssistant
{
    public static int RoundDecimal(string numberString) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main(string[] args)
    {
        var testCases = new List<Tuple<List<int>, Tuple<int, double>>>
        {
            Tuple.Create(new List<int> { 100, 150, 200, 250 }, Tuple.Create(4, 175.0)),
            Tuple.Create(new List<int>(), Tuple.Create(0, 0.0)),
            Tuple.Create(new List<int> { 50, 75, 100 }, Tuple.Create(3, 75.0)),
            Tuple.Create(new List<int> { -100, 0, 100 }, Tuple.Create(3, 0.0)),
            Tuple.Create(new List<int> { 1000 }, Tuple.Create(1, 1000.0))
        };

        foreach (var testCase in testCases)
        {
            var result = FinancialAnalyzer.CalculateStats(testCase.Item1);
            if (result.Item1 != testCase.Item2.Item1 || result.Item2 != testCase.Item2.Item2)
            {
                Console.WriteLine($"Test failed for input {testCase.Item1}: Expected ({testCase.Item2.Item1}, {testCase.Item2.Item2}), Got ({result.Item1}, {result.Item2})");
                return -1;
            }
        }

        Console.WriteLine("All tests passed successfully.");
        return 0;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class FinancialAnalyzer
{
    public static Tuple<int, double> CalculateStats(List<int> transactions)
    {
        if (transactions == null || transactions.Count == 0)
        {
            return Tuple.Create(0, 0.0);
        }
        else
        {
            int totalTransactions = transactions.Count;
            double averageAmount = transactions.Average();
            return Tuple.Create(totalTransactions, averageAmount);
        }
    }
    ;
        var result = CalculateStats(transactions);
        Console.WriteLine($"Total Transactions: {result.Item1}, Average Amount: {result.Item2}");
        var emptyTransactions = new List<int>();
        var emptyResult = CalculateStats(emptyTransactions);
        Console.WriteLine($"Total Transactions: {emptyResult.Item1}, Average Amount: {emptyResult.Item2}");
    }
}

Imagine you're working on a financial analysis tool and you need to process a series of transactions. Each transaction has an amount associated with it. Your task is to write a method that takes a list of these transaction amounts (as integers) and returns both the total number of transactions and the average transaction amount. However, if there are no transactions, the average should be reported as 0. Can you write a C# method to accomplish this?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialAnalyzer
{
    public static Tuple<int, double> CalculateStats(List<int> transactions)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

public class TextProcessorTest
{
    public static int Main(string[] args)
    {
        var testCases = new List<Tuple<string, List<string>>>
        {
            Tuple.Create("Hello; world, welcome to coding", new List<string> { "Hello", "world,", "welcome", "to", "coding" }),
            Tuple.Create("Coding;is;fun;and;educational", new List<string> { "Coding", "is", "fun", "and", "educational" }),
            Tuple.Create("Semicolons; are; also; separators", new List<string> { "Semicolons", "are", "also", "separators" })
        };

        bool allTestsPassed = true;

        foreach (var testCase in testCases)
        {
            var result = TextProcessor.SplitText(testCase.Item1);
            if (result.SequenceEqual(testCase.Item2))
            {
                Console.WriteLine($"Test passed for: {testCase.Item1}");
            }
            else
            {
                Console.WriteLine($"Test failed for: {testCase.Item1}");
                allTestsPassed = false;
            }
        }

        if (allTestsPassed)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
public class TextProcessor
{
    Takes a string containing words separated by semicolons or spaces and returns a list of words without semicolons.
    Example:
    - For the input "Hello; world, welcome to coding", the output should be a list: ["Hello", "world", "welcome", "to", "coding"].
    - For "Coding;is;fun;and;educational", the output should be: ["Coding", "is", "fun", "and", "educational"].
    public static List<string> SplitText(string text)
    {
        if (string.IsNullOrEmpty(text))
        {
            return new List<string>();
        }
        string unifiedText = text.Replace(';', ' ');
        return unifiedText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    }
    public static void CheckFunction()
    {
        var testData = new Dictionary<string, List<string>>()
        {
            { "Hello; world, welcome to coding", new List<string> { "Hello", "world,", "welcome", "to", "coding" } },
            { "Coding;is;fun;and;educational", new List<string> { "Coding", "is", "fun", "and", "educational" } }
        };
        foreach (var item in testData)
        {
            var result = SplitText(item.Key);
            if (result.SequenceEqual(item.Value))
            {
                Console.WriteLine($"Test passed for: {item.Key}");
            }
            else
            {
                Console.WriteLine($"Test failed for: {item.Key}");
            }
        }
    }
}
class Program
{

}

Imagine you're working on a text processing application where you need to handle strings containing sentences. These sentences are either separated by semicolons or spaces. Your challenge is to write a method that takes such a string and returns a list of individual words without any semicolons.

For instance, if you input the string "Hello; world, welcome to coding", your method should return a list containing ["Hello", "world", "welcome", "to", "coding"]. Similarly, for "Coding;is;fun;and;educational", the output should be ["Coding", "is", "fun", "and", "educational"].

Can you craft a C# method that accomplishes this task efficiently?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class TextProcessor
{
public class TextProcessor
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class TemperatureFilterTest {
    public static void Main(string[] args) {
        int result = RunTests();
        Environment.Exit(result);
    }

    public static int RunTests() {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> test1 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-5, 23, -2, 0, 15, -8, 30});
        List<int> expected1 = new List<int>{23, 0, 15, 30};
        allTestsPassed &= test1.SequenceEqual(expected1);

        // Test Case 2
        List<int> test2 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-1, -3, -5, -7});
        List<int> expected2 = new List<int>{};
        allTestsPassed &= test2.SequenceEqual(expected2);

        // Test Case 3
        List<int> test3 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{10, 20, 30, 40, 50});
        List<int> expected3 = new List<int>{10, 20, 30, 40, 50};
        allTestsPassed &= test3.SequenceEqual(expected3);

        // Test Case 4
        List<int> test4 = TemperatureFilter.FilterNonNegativeTemperatures(new List<int>{-10, -20, -30, -40, -50});
        List<int> expected4 = new List<int>{};
        allTestsPassed &= test4.SequenceEqual(expected4);

        if (allTestsPassed) {
            Console.WriteLine("All tests passed successfully.");
            return 0;
        } else {
            Console.WriteLine("There are test failures.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class TemperatureFilter {
    public static List<int> FilterNonNegativeTemperatures(List<int> temperatures) {
        List<int> nonNegativeTemperatures = new List<int>();
        foreach (int temp in temperatures) {
            if (temp >= 0) {
                nonNegativeTemperatures.Add(temp);
            }
        }
        return nonNegativeTemperatures;
    }
    public static void Check() {
        bool isCorrect = true;
        List<int> test1 = FilterNonNegativeTemperatures(new List<int>{-5, 23, -2, 0, 15, -8, 30});
        List<int> expected1 = new List<int>{23, 0, 15, 30};
        isCorrect &= test1.SequenceEqual(expected1);
        List<int> test2 = FilterNonNegativeTemperatures(new List<int>{-1, -3, -5, -7});
        List<int> expected2 = new List<int>{};
        isCorrect &= test2.SequenceEqual(expected2);
        if (isCorrect) {
            Console.WriteLine("All tests passed successfully.");
        } else {
            Console.WriteLine("There are test failures.");
        }
    }

}

Imagine you're working on a project where you need to filter out all the negative temperatures from a list of daily temperature readings. The readings are in Celsius and are represented as integers. Your task is to write a method that takes a list of these temperature readings and returns a new list containing only the non-negative temperatures. Make sure to include necessary imports at the beginning of your code snippet. Additionally, provide a method to verify the correctness of your solution with given data points.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class TemperatureFilter
{
    public static List<int> FilterNonNegativeTemperatures(List<int> temperatures) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class TemperatureAnalyzerTest
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        return TemperatureAnalyzer.GetUniqueSortedTemperatures(readings);
    }

    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> input1 = new List<int> { 30, 22, 20, 22, 30, 20, 31, 20 };
        List<int> expected1 = new List<int> { 20, 22, 30, 31 };
        List<int> result1 = GetUniqueSortedTemperatures(input1);
        allTestsPassed &= result1.SequenceEqual(expected1);

        // Test Case 2
        List<int> input2 = new List<int> { 15, 15, 15, 15, 15 };
        List<int> expected2 = new List<int> { 15 };
        List<int> result2 = GetUniqueSortedTemperatures(input2);
        allTestsPassed &= result2.SequenceEqual(expected2);

        // Test Case 3
        List<int> input3 = new List<int> { -10, -20, -30, -20, -10, -30 };
        List<int> expected3 = new List<int> { -30, -20, -10 };
        List<int> result3 = GetUniqueSortedTemperatures(input3);
        allTestsPassed &= result3.SequenceEqual(expected3);

        // Test Case 4
        List<int> input4 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        List<int> expected4 = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
        List<int> result4 = GetUniqueSortedTemperatures(input4);
        allTestsPassed &= result4.SequenceEqual(expected4);

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class TemperatureAnalyzer
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        List<int> uniqueSortedReadings = readings.Distinct().OrderBy(x => x).ToList();
        return uniqueSortedReadings;
    }
    ;
        List<int> expectedOutput = new List<int> { 20, 22, 30, 31 };
        List<int> result = GetUniqueSortedTemperatures(temperatureReadings);
        Console.WriteLine("Unique and Sorted Temperatures: " + String.Join(", ", result));
        Debug.Assert(result.SequenceEqual(expectedOutput), "The method did not return the expected result.");
    }
}

Imagine you're working on a project where you need to analyze a collection of numerical data. Specifically, you're tasked with finding the distinct elements within a series of temperature readings recorded in Celsius. These readings have been collected over several days, and due to some glitches in the data collection process, there are duplicate readings. Your goal is to write a C# method that takes a list of integer temperature readings and returns a new list containing only the unique temperatures, sorted in ascending order. This will help in identifying the range of temperature fluctuations more clearly.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class TemperatureAnalyzer
{
    public static List<int> GetUniqueSortedTemperatures(List<int> readings)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;

#<INSERT>

class NumberTransformerTest
{
    public static void Main(string[] args)
    {
        var testCases = new Dictionary<List<int>, List<string>>
        {
            { new List<int> { 2, 1, 1, 4, 5, 8, 2, 3 }, new List<string> { "Eight", "Five", "Four", "Three", "Two", "Two", "One", "One" } },
            { new List<int>(), new List<string>() },
            { new List<int> { 1, -1, 55 }, new List<string> { "One" } },
            { new List<int> { 9, 7, 3, 6 }, new List<string> { "Nine", "Seven", "Six", "Three" } },
            { new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, new List<string> { "Nine", "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One" } }
        };

        int failedTests = 0;

        foreach (var testCase in testCases)
        {
            var output = NumberTransformer.TransformNumbersToWords(testCase.Key);
            bool isCorrect = output.SequenceEqual(testCase.Value);
            Console.WriteLine($"Input: [{string.Join(", ", testCase.Key)}]");
            Console.WriteLine($"Output: [{string.Join(", ", output)}]");
            Console.WriteLine($"Is Correct: {isCorrect}\n");

            if (!isCorrect)
            {
                failedTests++;
            }
        }

        if (failedTests > 0)
        {
            Console.WriteLine($"Failed {failedTests} tests.");
            Environment.Exit(-1);
        }

        Console.WriteLine("All tests passed.");
        Environment.Exit(0);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
using System.Linq;
class NumberTransformer
{
    public static List<string> TransformNumbersToWords(List<int> numbers)
    {
        string[] numberWords = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
        List<string> result = numbers
            .Where(n => n >= 1 && n <= 9)
            .OrderBy(n => n)
            .Reverse()
            .Select(n => numberWords[n - 1])
            .ToList();
        return result;
    }
    public static void Check()
    {
        var testCases = new Dictionary<List<int>, List<string>>
        {
            { new List<int> { 2, 1, 1, 4, 5, 8, 2, 3 }, new List<string> { "Eight", "Five", "Four", "Three", "Two", "Two", "One", "One" } },
            { new List<int>(), new List<string>() },
            { new List<int> { 1, -1, 55 }, new List<string> { "One" } }
        };
        foreach (var testCase in testCases)
        {
            var output = TransformNumbersToWords(testCase.Key);
            bool isCorrect = output.SequenceEqual(testCase.Value);
            Console.WriteLine($"Input: [{string.Join(", ", testCase.Key)}]");
            Console.WriteLine($"Output: [{string.Join(", ", output)}]");
            Console.WriteLine($"Is Correct: {isCorrect}\n");
        }
    }
}
class Program
{

}

Imagine you have a collection of integer values, and you need to perform a specific transformation on this collection. Your task is to write a method in C# that takes a list of integers and processes it according to the following rules:

1. Filter out all integers that are not within the range of 1 to 9, inclusive.
2. Sort the remaining integers in ascending order.
3. Reverse the sorted list.
4. Convert each integer to its corresponding English word representation ("One" for 1, "Two" for 2, etc.).

For example, if the input list is `[2, 1, 1, 4, 5, 8, 2, 3]`, the output should be `["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"]`. If the input list is empty or contains no integers within the range of 1 to 9, the output should be an empty list. Any integers outside the range of 1 to 9 should be ignored.

Write a C# method named `TransformNumbersToWords` that implements this functionality. Additionally, include a check function with provided data points to verify the correctness of your method.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class NumberTransformer
{
    public static List<string> TransformNumbersToWords(List<int> numbers)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class TransactionAnalyzerTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{1, 3, -1, 4}) == true;

        // Test Case 2
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{5, 7, 2}) == false;

        // Test Case 3
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{0, -5, 5, 10}) == true;

        // Test Case 4
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{}) == false;

        // Test Case 5
        allTestsPassed &= TransactionAnalyzer.HasCancelingTransactions(new List<int>{-1, 1, 2, -2, 3, -3}) == true;

        if (allTestsPassed) {
            Console.WriteLine("All tests passed!");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class TransactionAnalyzer {
    public static bool HasCancelingTransactions(List<int> transactions) {
        HashSet<int> seen = new HashSet<int>();
        foreach (int amount in transactions) {
            if (seen.Contains(-amount)) {
                return true;
            }
            seen.Add(amount);
        }
        return false;
    }
    public static void Check() {
        Debug.Assert(HasCancelingTransactions(new List<int>{1, 3, -1, 4}) == true);
        Debug.Assert(HasCancelingTransactions(new List<int>{5, 7, 2}) == false);
        Debug.Assert(HasCancelingTransactions(new List<int>{0, -5, 5, 10}) == true);
        Debug.Assert(HasCancelingTransactions(new List<int>{}) == false);
        Console.WriteLine("All checks passed!");
    }

}

Imagine you're working on a feature for a financial software application that needs to quickly identify if any two transactions cancel each other out. Specifically, you're tasked with writing a method that checks if there are any two distinct transactions whose amounts sum to exactly zero. This could be useful, for example, in detecting errors or potential fraudulent activity. Your method should accept a list of transaction amounts (as integers) and return `true` if there exists at least one pair of transactions that sum to zero, and `false` otherwise.

Can you design a C# method that accomplishes this task efficiently?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class TransactionAnalyzer
{
    public static bool HasCancelingTransactions(List<int> transactions) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class EmailValidatorTest {
    public static void Main(string[] args) {
        int result = 0;
        var testCases = new List<Tuple<string, string>> {
            Tuple.Create("example@domain.com", "Valid"),
            Tuple.Create("1example@domain.com", "Invalid"),
            Tuple.Create("example@domain.co.uk", "Invalid"),
            Tuple.Create("example@domain.net", "Valid"),
            Tuple.Create("example@domain.org", "Valid")
        };

        foreach (var testCase in testCases) {
            string input = testCase.Item1;
            string expected = testCase.Item2;
            string actual = EmailValidator.ValidateEmail(input);

            if (actual != expected) {
                Console.WriteLine($"Test failed for input: {input}. Expected: {expected}, Actual: {actual}");
                result = -1;
            }
        }

        if (result == 0) {
            Console.WriteLine("All tests passed!");
        } else {
            Console.WriteLine("Some tests failed.");
        }

        Environment.Exit(result);
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class EmailValidator {
    public static string ValidateEmail(string email) {
        string[] allowedDomainExtensions = { "com", "net", "org" };
        int atIndex = email.IndexOf('@');
        int dotIndex = email.LastIndexOf('.');
        if (atIndex > 0 && dotIndex > atIndex + 1) {
            string localPart = email.Substring(0, atIndex);
            string domainPart = email.Substring(atIndex + 1, dotIndex - atIndex - 1);
            string domainExtension = email.Substring(dotIndex + 1);
            if (char.IsDigit(localPart[0]) || !allowedDomainExtensions.Contains(domainExtension)) {
                return "Invalid";
            }
            return "Valid";
        }
        return "Invalid";
    }

}

Can you write a C# method that determines whether a provided email address is considered valid? An email is deemed valid if it meets all the following criteria:
- It contains exactly one '@' symbol.
- The local part (before the '@') must not start with a digit and must be at least one character long.
- The domain part (after the '@') must contain exactly one dot ('.').
- The substring after the domain's dot must be either 'com', 'net', or 'org'.
Test the function with a few email addresses to verify its correctness.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class EmailValidator
{
    public static string ValidateEmail(string email) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class RhythmParserTest
{
    public static int Main(string[] args)
    {
        List<Tuple<string, List<double>>> testCases = new List<Tuple<string, List<double>>>
        {
            Tuple.Create("x x- *- x- x-", new List<double> { 1.0, 0.5, 0.25, 0.5, 0.5 }),
            Tuple.Create("x x x- *-", new List<double> { 1.0, 1.0, 0.5, 0.25 }),
            Tuple.Create("*-*- x", new List<double> { 0.25, 0.25, 1.0 }),
            Tuple.Create("x- x- x-", new List<double> { 0.5, 0.5, 0.5 }),
            Tuple.Create("x *-", new List<double> { 1.0, 0.25 })
        };

        int failedTests = 0;

        foreach (var testCase in testCases)
        {
            List<double> result = RhythmParser.ParseRhythms(testCase.Item1);
            if (!result.SequenceEqual(testCase.Item2))
            {
                Console.WriteLine($"Test failed for input '{testCase.Item1}': Expected {string.Join(", ", testCase.Item2)} but got {string.Join(", ", result)}");
                failedTests++;
            }
        }

        if (failedTests > 0)
        {
            return -1;
        }

        Console.WriteLine("All tests passed.");
        return 0;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class RhythmParser
{
    public static List<double> ParseRhythms(string rhythmString)
    {
        List<double> durations = new List<double>();
        for (int i = 0; i < rhythmString.Length; i++)
        {
            switch (rhythmString[i])
            {
                case 'x':
                    if (i + 1 < rhythmString.Length && rhythmString[i + 1] == '-')
                    {
                        durations.Add(0.5);
                        i++;
                    }
                    else
                    {
                        durations.Add(1.0);
                    }
                    break;
                case '*':
                    if (i + 1 < rhythmString.Length && rhythmString[i + 1] == '-')
                    {
                        durations.Add(0.25);
                        i++;
                    }
                    break;
            }
        }
        return durations;
    }

    }
}

Imagine you're developing a feature for a music education app that helps users understand rhythm patterns. You need to write a function that interprets a string of ASCII art representing different rhythmic values in music notation and converts it into a list of durations. Each character or combination of characters in the string represents a specific note duration:

- 'x' stands for a quarter note, which lasts 1 beat.
- 'x-' represents an eighth note, lasting half a beat.
- '*-' denotes a sixteenth note, which lasts a quarter of a beat.

Given a string of these characters, your task is to parse it and return a list of doubles, where each element represents the duration of the corresponding note in beats. For example, if the input string is "x x- *- x- x-", the output should be a list containing the values [1.0, 0.5, 0.25, 0.5, 0.5].

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class RhythmParser
{
    public static List<double> ParseRhythms(string rhythmString)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class RhythmParserTest {
    public static int Main(string[] args) {
        // Test cases
        var testCases = new List<Tuple<string, List<int>>> {
            Tuple.Create("X X| - X| X| - - - X X", new List<int> { 4, 2, 1, 2, 2, 1, 1, 1, 4, 4 }),
            Tuple.Create("X X| - -", new List<int> { 4, 2, 1, 1 }),
            Tuple.Create("X| X - X| -", new List<int> { 2, 4, 1, 2, 1 }),
            Tuple.Create("X X X", new List<int> { 4, 4, 4 }),
            Tuple.Create("- - - -", new List<int> { 1, 1, 1, 1 })
        };

        bool allTestsPassed = true;
        foreach (var testCase in testCases) {
            var result = RhythmParser.ParseRhythms(testCase.Item1);
            if (!result.SequenceEqual(testCase.Item2)) {
                Console.WriteLine($"Test failed for input: {testCase.Item1}");
                Console.WriteLine($"Expected: [{string.Join(", ", testCase.Item2)}]");
                Console.WriteLine($"Actual: [{string.Join(", ", result)}]");
                allTestsPassed = false;
            }
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class RhythmParser {
    public static List<int> ParseRhythms(string rhythm) {
        List<int> beats = new List<int>();
        int i = 0;
        while (i < rhythm.Length) {
            if (rhythm[i] == 'X') {
                if (i + 1 < rhythm.Length && rhythm[i + 1] == '|') {
                    beats.Add(2);
                    i += 2;
                } else {
                    beats.Add(4);
                    i++;
                }
            } else if (rhythm[i] == '-') {
                beats.Add(1);
                i++;
            } else {
                i++;
            }
        }
        return beats;
    }
    ]");
    }
}

Imagine you're developing a feature for a music education app that teaches users to understand the rhythm of sheet music. The app needs a way to convert textual representations of rhythms into the number of beats they represent. Each rhythm is represented by a specific character pattern in a string. Your task is to create a function that takes a string of rhythm patterns and returns a list of integers, where each integer represents the number of beats for each rhythm pattern. Use the following character patterns:

- `'X'` represents a whole note, lasting four beats.
- `'X|'` represents a half note, lasting two beats.
- `'-'` represents a quarter note, lasting one beat.

For example, if the input string is `"X X| - X| X| - - - X X"`, your function should return a list of integers corresponding to the beats: `[4, 2, 1, 2, 2, 1, 1, 1, 4, 4]`.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class RhythmParser
{
    public static List<int> ParseRhythms(string rhythm) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<long> test1 = new List<long> { 2, 3, 4, 1, 2, 4 };
        long result1 = FinancialAnalyzer.FindLeastProfitablePeriod(test1);
        if (result1 != 1)
        {
            Console.WriteLine($"Test 1 Failed: Expected 1, Got {result1}");
            allTestsPassed = false;
        }

        // Test Case 2
        List<long> test2 = new List<long> { -1, -2, -3 };
        long result2 = FinancialAnalyzer.FindLeastProfitablePeriod(test2);
        if (result2 != -6)
        {
            Console.WriteLine($"Test 2 Failed: Expected -6, Got {result2}");
            allTestsPassed = false;
        }

        // Test Case 3
        List<long> test3 = new List<long> { 100, 200, -500, 300, 100, -400, 200 };
        long result3 = FinancialAnalyzer.FindLeastProfitablePeriod(test3);
        if (result3 != -500)
        {
            Console.WriteLine($"Test 3 Failed: Expected -500, Got {result3}");
            allTestsPassed = false;
        }

        // Test Case 4
        List<long> test4 = new List<long> { 5, -1, -2, 3, -4, 2, 1 };
        long result4 = FinancialAnalyzer.FindLeastProfitablePeriod(test4);
        if (result4 != -4)
        {
            Console.WriteLine($"Test 4 Failed: Expected -4, Got {result4}");
            allTestsPassed = false;
        }

        // Test Case 5
        List<long> test5 = new List<long> { 1, 2, 3, 4, 5 };
        long result5 = FinancialAnalyzer.FindLeastProfitablePeriod(test5);
        if (result5 != 1)
        {
            Console.WriteLine($"Test 5 Failed: Expected 1, Got {result5}");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed!");
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class FinancialAnalyzer
{
    public static long FindLeastProfitablePeriod(List<long> transactions)
    {
        if (transactions == null || transactions.Count == 0)
        {
            throw new ArgumentException("The transactions list cannot be null or empty.");
        }
        long minSum = transactions[0], currentSum = transactions[0];
        for (int i = 1; i < transactions.Count; i++)
        {
            currentSum = Math.Min(transactions[i], currentSum + transactions[i]);
            minSum = Math.Min(minSum, currentSum);
        }
        return minSum;
    }
    ));
        Console.WriteLine(FindLeastProfitablePeriod(new List<long> { -1, -2, -3 }));
        Console.WriteLine(FindLeastProfitablePeriod(new List<long> { 100, 200, -500, 300, 100, -400, 200 }));
    }
}

Imagine you're working on a financial analysis tool that needs to process large datasets of daily transaction amounts. Your task is to write a C# method that finds the smallest possible sum of any continuous sequence of transactions. This could be useful, for example, in identifying the least profitable period. The method should accept a list of integers representing daily transaction amounts and return the minimum sum of any contiguous subsequence.

For instance, if you have a week's worth of transactions like `[100, 200, -500, 300, 100, -400, 200]`, the method should identify the period where the sum is the smallest (in this case, `-500 + 300 + 100 - 400 = -500`). Note that the transactions could also be all positive or all negative.

Can you write a C# method that accomplishes this task efficiently?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialAnalyzer
{
    public static long FindLeastProfitablePeriod(List<long> transactions)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;

#<INSERT>

class DigitSumCalculatorTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        if (DigitSumCalculator.SumLastDigits(123, 456) != 9) {
            Console.WriteLine("Test 1 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 1 Passed");
        }

        // Test Case 2
        if (DigitSumCalculator.SumLastDigits(-97, 32) != 9) {
            Console.WriteLine("Test 2 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 2 Passed");
        }

        // Test Case 3
        if (DigitSumCalculator.SumLastDigits(1000, -300) != 0) {
            Console.WriteLine("Test 3 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 3 Passed");
        }

        // Test Case 4
        if (DigitSumCalculator.SumLastDigits(-15, -25) != 10) {
            Console.WriteLine("Test 4 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 4 Passed");
        }

        // Test Case 5
        if (DigitSumCalculator.SumLastDigits(0, 0) != 0) {
            Console.WriteLine("Test 5 Failed");
            allTestsPassed = false;
        } else {
            Console.WriteLine("Test 5 Passed");
        }

        return allTestsPassed ? 0 : -1;
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
class DigitSumCalculator {
    public static int SumLastDigits(int num1, int num2) {
        int lastDigit1 = Math.Abs(num1) % 10;
        int lastDigit2 = Math.Abs(num2) % 10;
        int sum = lastDigit1 + lastDigit2;
        return sum;
    }
    public static void Check() {
        Console.WriteLine(SumLastDigits(123, 456) == 9 ? "Test 1 Passed" : "Test 1 Failed");
        Console.WriteLine(SumLastDigits(-97, 32) == 9 ? "Test 2 Passed" : "Test 2 Failed");
        Console.WriteLine(SumLastDigits(1000, -300) == 0 ? "Test 3 Passed" : "Test 3 Failed");
        Console.WriteLine(SumLastDigits(-15, -25) == 10 ? "Test 4 Passed" : "Test 4 Failed");
    }

}

Imagine you're working on a software project that requires you to design a function capable of determining the sum of the last digits of any two given positive or negative integers. This task is crucial for a feature in a financial application where transactions often need calculations based on the smallest denomination of currencies. Your challenge is to write a self-contained C# code snippet that includes all necessary imports, follows best practices, and is easy to understand. The function should take two integers as input and return the sum of their last digits. For example, if the function is given the numbers 123 and 456, it should return 9, as 3 (the last digit of 123) plus 6 (the last digit of 456) equals 9. Ensure your solution is efficient and handles both positive and negative numbers gracefully.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class DigitSumCalculator
{
    public static int SumLastDigits(int num1, int num2) {
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialCalculatorTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        allTestsPassed &= TestGetCents(123.45f, 45f);
        allTestsPassed &= TestGetCents(99.99f, 99f);
        allTestsPassed &= TestGetCents(0.01f, 1f);
        allTestsPassed &= TestGetCents(100.00f, 0f);
        allTestsPassed &= TestGetCents(250.75f, 75f);

        return allTestsPassed ? 0 : -1;
    }

    private static bool TestGetCents(float input, float expected)
    {
        FinancialCalculator calculator = new FinancialCalculator();
        float result = calculator.GetCents(input);

        if (Math.Abs(result - expected) < 0.01f)
        {
            Console.WriteLine($"Test passed for input: {input}");
            return true;
        }
        else
        {
            Console.WriteLine($"Test failed for input: {input}. Expected: {expected}, but got: {result}");
            return false;
        }
    }
}

public class FinancialCalculator
{
    /// <summary>
    /// This method separates the cents from a given amount of money in dollars.
    /// </summary>
    /// <param name="amount">The amount in dollars and cents</param>
    /// <returns>The cents as a separate floating-point number</returns>
    public float GetCents(float amount)
    {
        // Get the fractional part of the amount
        float fractionalPart = amount - (int)amount;

        // Convert the fractional part to cents
        float cents = fractionalPart * 100;

        // Return the cents rounded to two decimal places
        return (float)Math.Round(cents, 2);
    }
}

Imagine you're working on a financial application where precise calculations are crucial. You need to write a function that can separate the cents from a given amount of money in dollars. For instance, if you have $123.45, you want to isolate the 45 cents as a separate floating-point number. How would you design a function in C# to accomplish this, ensuring that it can handle any positive floating-point number representing dollars and cents?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialCalculator
{
public class FinancialCalculator
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class AccountTrackerTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> transactions1 = new List<int> { 1, 2, 3 };
        bool result1 = AccountTracker.DetectOverdraft(transactions1);
        if (result1 != false) {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        List<int> transactions2 = new List<int> { 1, 2, -4, 5 };
        bool result2 = AccountTracker.DetectOverdraft(transactions2);
        if (result2 != true) {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        List<int> transactions3 = new List<int> { -1, -2, 4, -5, 6 };
        bool result3 = AccountTracker.DetectOverdraft(transactions3);
        if (result3 != true) {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        List<int> transactions4 = new List<int> { 10, -5, -3, -2 };
        bool result4 = AccountTracker.DetectOverdraft(transactions4);
        if (result4 != false) {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        List<int> transactions5 = new List<int> { -10, 5, 5 };
        bool result5 = AccountTracker.DetectOverdraft(transactions5);
        if (result5 != true) {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class AccountTracker {
    public static bool DetectOverdraft(List<int> transactions) {
        int balance = 0;
        foreach (var transaction in transactions) {
            balance += transaction;
            if (balance < 0) {
                return true;
            }
        }
        return false;
    }
    public ));
        Console.WriteLine(DetectOverdraft(new List<int>{1, 2, -4, 5}));
        Console.WriteLine(DetectOverdraft(new List<int>{-1, -2, 4, -5, 6}));
    }
}

Let's say you're working on a financial application that needs to track the balance of a user's account over a series of transactions. Each transaction could either be a deposit (positive value) or a withdrawal (negative value). The account starts with a balance of zero. You are tasked with writing a method that goes through a list of these transactions and determines if at any point the account's balance drops below zero. If it does, the method should return `true`, indicating that the account went into overdraft. If the balance never drops below zero throughout all the transactions, the method should return `false`.

Can you write a C# method that accomplishes this? Make sure to include necessary imports and create a self-contained code snippet with a check function using provided data points.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class AccountTracker
{
    public ));
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;

#<INSERT>

class EmailValidationTest {
    public static int Main(string[] args) {
        bool allTestsPassed = true;

        // Test Case 1
        string result1 = EmailValidation.EmailValidator("example.email@domain.com");
        if (result1 != "Valid") {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        string result2 = EmailValidation.EmailValidator("_example@domain.com");
        if (result2 != "Invalid") {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        string result3 = EmailValidation.EmailValidator("example@domain.ccom");
        if (result3 != "Invalid") {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        string result4 = EmailValidation.EmailValidator("example@domain.com");
        if (result4 != "Valid") {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        string result5 = EmailValidation.EmailValidator("example@domain..com");
        if (result5 != "Invalid") {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed) {
            Console.WriteLine("All tests passed.");
            return 0;
        } else {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Text.RegularExpressions;
class EmailValidation {
    public static string EmailValidator(string email) {
        string pattern = @"^[a-zA-Z][a-zA-Z0-9._]*@[a-z]+\.(com|net|org)$";
        if (Regex.IsMatch(email, pattern)) {
            int atCount = email.Count(f => f == '@');
            int dotCount = email.Split('@')[1].Count(f => f == '.');
            if (atCount == 1 && dotCount >= 1) {
                return "Valid";
            }
        }
        return "Invalid";
    }

}

Can you write a method that checks if an email address is valid based on specific criteria? The method should accept a string representing an email address and return "Valid" if the email address meets all the criteria, or "Invalid" otherwise. The criteria for a valid email address are as follows:
- It must contain exactly one '@' symbol.
- The local part (before the '@') must start with a letter (either uppercase or lowercase) and may include letters, digits, dots ('.'), and underscores ('_'), but it cannot start with a dot or underscore.
- The domain part (after the '@') must contain at least one dot ('.'), and the last portion of the domain (after the last dot) must be either 'com', 'net', or 'org'.
- The domain part must only consist of lowercase letters before the last dot.

Here's an example of how your method should work:
```csharp
// Example usage
Console.WriteLine(EmailValidator("example.email@domain.com")); // Output: "Valid"
Console.WriteLine(EmailValidator("invalid-email@domain.com")); // Output: "Invalid"
```

Ensure your solution includes necessary imports, a clear method signature, and a check function with provided data points to verify the correctness of your solution.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class EmailValidation
{
    public static string EmailValidator(string email) {
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class MusicDurationParserTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        List<int> result1 = MusicDurationParser.ConvertNoteDurations("W H- Q-");
        List<int> expected1 = new List<int> { 4, 2, 1 };
        if (!result1.SequenceEqual(expected1))
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        List<int> result2 = MusicDurationParser.ConvertNoteDurations("Q- Q- Q- Q-");
        List<int> expected2 = new List<int> { 1, 1, 1, 1 };
        if (!result2.SequenceEqual(expected2))
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        List<int> result3 = MusicDurationParser.ConvertNoteDurations("W W W");
        List<int> expected3 = new List<int> { 4, 4, 4 };
        if (!result3.SequenceEqual(expected3))
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        List<int> result4 = MusicDurationParser.ConvertNoteDurations("H- H- H- H-");
        List<int> expected4 = new List<int> { 2, 2, 2, 2 };
        if (!result4.SequenceEqual(expected4))
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        List<int> result5 = MusicDurationParser.ConvertNoteDurations("W H- Q- H- H- Q- Q- Q- Q- W W");
        List<int> expected5 = new List<int> { 4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4 };
        if (!result5.SequenceEqual(expected5))
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class MusicDurationParser
{
    public static List<int> ConvertNoteDurations(string notes)
    {
        List<int> durations = new List<int>();
        string[] noteArray = notes.Split(' ');
        foreach (string note in noteArray)
        {
            switch (note)
            {
                case "W":
                    durations.Add(4);
                    break;
                case "H-":
                    durations.Add(2);
                    break;
                case "Q-":
                    durations.Add(1);
                    break;
                default:
                    throw new ArgumentException("Unknown note encountered.");
            }
        }
        return durations;
    }
    ;
        List<int> actualDurations = ConvertNoteDurations(testNotes);
        Console.WriteLine($"Expected: {string.Join(", ", expectedDurations)}");
        Console.WriteLine($"Actual: {string.Join(", ", actualDurations)}");
    }
}

Imagine you're developing a feature for a music education app that helps users understand the duration of different notes in a musical composition. You're tasked with writing a C# method that interprets a string of musical notes, each represented by a unique ASCII character sequence, and converts them into their respective durations in terms of beats. The notation is as follows:

- 'W' represents a whole note, which lasts four beats.
- 'H' followed by a dash 'H-' represents a half note, lasting two beats.
- 'Q' followed by a dash 'Q-' signifies a quarter note, which lasts one beat.

Write a method `ConvertNoteDurations` that takes a single string argument containing a sequence of these note representations and returns a list of integers, where each integer represents the duration in beats of the corresponding note in the input string.

For example, if the input string is "W H- Q- H- H- Q- Q- Q- Q- W W", the method should return a list of integers corresponding to the beats of each note: `[4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]`.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class MusicDurationParser
{
    public static List<int> ConvertNoteDurations(string notes)
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Linq;

#<INSERT>

class StringStrengthEvaluatorTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test case 1
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("") != 0)
        {
            Console.WriteLine("Test case 1 failed.");
            allTestsPassed = false;
        }

        // Test case 2
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("abAB") != 131)
        {
            Console.WriteLine("Test case 2 failed.");
            allTestsPassed = false;
        }

        // Test case 3
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("abcCd") != 67)
        {
            Console.WriteLine("Test case 3 failed.");
            allTestsPassed = false;
        }

        // Test case 4
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("helloE") != 69)
        {
            Console.WriteLine("Test case 4 failed.");
            allTestsPassed = false;
        }

        // Test case 5
        if (StringStrengthEvaluator.CalculateUppercaseAsciiSum("woArBld") != 131)
        {
            Console.WriteLine("Test case 5 failed.");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All test cases passed.");
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Linq;
class StringStrengthEvaluator
{
    public static long CalculateUppercaseAsciiSum(string input)
    {
        return input.Where(char.IsUpper).Sum(c => (long)c);
    }

}

Imagine you're working on a security application where you need to analyze the strength of various strings based on their uppercase characters. You are tasked with writing a method in C# that evaluates the strength of a given string by calculating the sum of the ASCII values of all uppercase letters in the string. The method should return a `long` representing this sum.

Here are some requirements for the method:

- The method should be named `CalculateUppercaseAsciiSum`.
- It should accept a single `string` parameter.
- It should return a `long` value representing the sum of the ASCII values of all uppercase characters in the input string.
- If the string does not contain any uppercase characters, the method should return `0`.

For example, if the input string is `"HelloWorld"`, the method should return the sum of the ASCII values of `'H'`, `'W'`, and `'D'`.

Write a self-contained code snippet that includes the method and a check function with provided data points to verify the correctness of the method.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class StringStrengthEvaluator
{
    public static long CalculateUppercaseAsciiSum(string input)
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialDataAnalyzerTest
{
    public static int Main()
    {
        FinancialDataAnalyzer analyzer = new FinancialDataAnalyzer();
        bool allTestsPassed = true;

        // Test Case 1: Regular case with mixed positive and negative values
        int[] testCase1 = { 2, 3, -6, 4, 2 };
        int expected1 = -6;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase1) == expected1);

        // Test Case 2: All positive values
        int[] testCase2 = { 1, 2, 3, 4, 5 };
        int expected2 = 1;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase2) == expected2);

        // Test Case 3: All negative values
        int[] testCase3 = { -1, -2, -3, -4, -5 };
        int expected3 = -15;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase3) == expected3);

        // Test Case 4: Mixed values with the minimum sum in the middle
        int[] testCase4 = { 3, -4, 2, -3, -1, 4, -5 };
        int expected4 = -5;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase4) == expected4);

        // Test Case 5: Single element array
        int[] testCase5 = { -10 };
        int expected5 = -10;
        allTestsPassed &= (analyzer.FindMinimumSumOfContiguousSubsequence(testCase5) == expected5);

        return allTestsPassed ? 0 : -1;
    }
}

public class FinancialDataAnalyzer
{
    public int FindMinimumSumOfContiguousSubsequence(int[] dailySpending)
    {
        if (dailySpending == null || dailySpending.Length == 0)
        {
            throw new ArgumentException("The daily spending array must not be null or empty.");
        }

        int minSum = dailySpending[0];
        int currentSum = dailySpending[0];

        for (int i = 1; i < dailySpending.Length; i++)
        {
            currentSum = Math.Min(dailySpending[i], currentSum + dailySpending[i]);
            minSum = Math.Min(minSum, currentSum);
        }

        return minSum;
    }
}

Imagine you're working on a project that involves analyzing financial data. You need to find periods of time where spending was at its lowest, even if it means looking at individual days. To solve this, you're tasked with writing a method in C# that calculates the smallest possible sum of a contiguous subsequence within an array of daily spending amounts (which could be positive or negative). How would you design a method that takes an array of integers representing daily spending and returns the minimum sum of any contiguous subsequence? For instance, if given an array of [2, 3, -6, 4, 2], the method should return -6, as choosing the subsequence [-6] yields the smallest sum.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialDataAnalyzer
{
public class FinancialDataAnalyzer
    {
        // Implement your code here.
    }
}
```


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;

#<INSERT>

class FinancialAnalyzerTest
{
    public static int Main()
    {
        bool allTestsPassed = true;

        // Test Case 1
        var result1 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 5, 20, 10 });
        if (result1.Item1 != 35 || result1.Item2 != 1000)
        {
            Console.WriteLine("Test Case 1 Failed");
            allTestsPassed = false;
        }

        // Test Case 2
        var result2 = FinancialAnalyzer.CalculateSumAndProduct(new List<int>());
        if (result2.Item1 != 0 || result2.Item2 != 1)
        {
            Console.WriteLine("Test Case 2 Failed");
            allTestsPassed = false;
        }

        // Test Case 3
        var result3 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 1, 2, 3, 4 });
        if (result3.Item1 != 10 || result3.Item2 != 24)
        {
            Console.WriteLine("Test Case 3 Failed");
            allTestsPassed = false;
        }

        // Test Case 4
        var result4 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { -1, -2, -3, -4 });
        if (result4.Item1 != -10 || result4.Item2 != 24)
        {
            Console.WriteLine("Test Case 4 Failed");
            allTestsPassed = false;
        }

        // Test Case 5
        var result5 = FinancialAnalyzer.CalculateSumAndProduct(new List<int> { 0, 0, 0 });
        if (result5.Item1 != 0 || result5.Item2 != 0)
        {
            Console.WriteLine("Test Case 5 Failed");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            Console.WriteLine("All tests passed.");
            return 0;
        }
        else
        {
            Console.WriteLine("Some tests failed.");
            return -1;
        }
    }
}

using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Diagnostics;
using System.Numerics;
using System;
using System.Collections.Generic;
class FinancialAnalyzer
{
    public static Tuple<int, int> CalculateSumAndProduct(List<int> stockPrices)
    {
        if (stockPrices == null || stockPrices.Count == 0)
        {
            return Tuple.Create(0, 1);
        }
        int sum = 0;
        int product = 1;
        foreach (int price in stockPrices)
        {
            sum += price;
            product *= price;
        }
        return Tuple.Create(sum, product);
    }
    );
        Console.WriteLine($"Sum: {result1.Item1}, Product: {result1.Item2}");
        var result2 = CalculateSumAndProduct(new List<int>());
        Console.WriteLine($"Sum: {result2.Item1}, Product: {result2.Item2}");
    }
}

You're working on a financial analysis tool and need a function that can take a list of stock prices (as integers) and calculate both the total sum and the cumulative product of all the prices. This function is crucial for understanding both the overall market trend and the compounded effect of price changes over time. If the list is empty, the total sum should default to 0, and the cumulative product should default to 1, as these are the neutral elements for addition and multiplication, respectively. Can you write a C# function that accomplishes this?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialAnalyzer
{
    public static Tuple<int, int> CalculateSumAndProduct(List<int> stockPrices)
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinanceUtilityTest
{
    public static int Main()
    {
        bool allTestsPassed = true;

        // Test Case 1: Normal range with largest even number
        if (FinanceUtility.FindLargestEvenNumber(1, 10) != 10)
        {
            allTestsPassed = false;
        }

        // Test Case 2: Range with no even number
        if (FinanceUtility.FindLargestEvenNumber(1, 1) != -1)
        {
            allTestsPassed = false;
        }

        // Test Case 3: Range with start greater than end
        if (FinanceUtility.FindLargestEvenNumber(10, 1) != -1)
        {
            allTestsPassed = false;
        }

        // Test Case 4: Normal range with largest even number being the start
        if (FinanceUtility.FindLargestEvenNumber(4, 7) != 6)
        {
            allTestsPassed = false;
        }

        // Test Case 5: Range with both start and end being the same even number
        if (FinanceUtility.FindLargestEvenNumber(8, 8) != 8)
        {
            allTestsPassed = false;
        }

        return allTestsPassed ? 0 : -1;
    }
}

public class FinanceUtility
{
    public static int FindLargestEvenNumber(int start, int end)
    {
        // Check if the range is valid
        if (start > end)
        {
            return -1;
        }

        // If the end number is even, start from it, otherwise start from the largest even number less than end
        int largestEven = end % 2 == 0 ? end : end - 1;

        // Check if the largest even number is within the range
        if (largestEven < start)
        {
            return -1;
        }

        return largestEven;
    }
}

You're working on a utility class for a new finance application that helps users with various calculations. One of the features you need to implement is a method to find the largest even number within a specific range. This range is defined by two numbers, a start and an end. Your task is to write a method that takes two arguments, `start` and `end` (both inclusive), and returns the largest even number within this range. If there are no even numbers in the range or if the start is greater than the end, the method should return `-1`.

Here are a couple of scenarios where this method would be useful:
- A user wants to know the largest even investment amount they can make that's within their specified budget range.
- Calculating the maximum even number within a given range for a financial report.

Ensure your method is efficient and handles edge cases gracefully.

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinanceUtility
{
public class FinanceUtility
    {
        // Implement your code here.
    }
}
```


using System;

#<INSERT>

public class FinancialUtilityTest
{
    public static int Main(string[] args)
    {
        bool allTestsPassed = true;

        // Test Case 1
        double testCase1 = 123.456;
        double expected1 = 0.456;
        double result1 = FinancialUtility.ExtractCents(testCase1);
        if (Math.Abs(result1 - expected1) > 0.0001)
        {
            Console.WriteLine($"Test Case 1 Failed: Expected {expected1}, Got {result1}");
            allTestsPassed = false;
        }

        // Test Case 2
        double testCase2 = 0.789;
        double expected2 = 0.789;
        double result2 = FinancialUtility.ExtractCents(testCase2);
        if (Math.Abs(result2 - expected2) > 0.0001)
        {
            Console.WriteLine($"Test Case 2 Failed: Expected {expected2}, Got {result2}");
            allTestsPassed = false;
        }

        // Test Case 3
        double testCase3 = 100.001;
        double expected3 = 0.001;
        double result3 = FinancialUtility.ExtractCents(testCase3);
        if (Math.Abs(result3 - expected3) > 0.0001)
        {
            Console.WriteLine($"Test Case 3 Failed: Expected {expected3}, Got {result3}");
            allTestsPassed = false;
        }

        // Test Case 4
        double testCase4 = 45.1234;
        double expected4 = 0.123;
        double result4 = FinancialUtility.ExtractCents(testCase4);
        if (Math.Abs(result4 - expected4) > 0.0001)
        {
            Console.WriteLine($"Test Case 4 Failed: Expected {expected4}, Got {result4}");
            allTestsPassed = false;
        }

        // Test Case 5
        double testCase5 = 0.0;
        double expected5 = 0.0;
        double result5 = FinancialUtility.ExtractCents(testCase5);
        if (Math.Abs(result5 - expected5) > 0.0001)
        {
            Console.WriteLine($"Test Case 5 Failed: Expected {expected5}, Got {result5}");
            allTestsPassed = false;
        }

        if (allTestsPassed)
        {
            return 0;
        }
        else
        {
            return -1;
        }
    }
}

using System;

public class FinancialUtility
{
    // Method to extract and return the cents part of a monetary value
    public static double ExtractCents(double amount)
    {
        // Calculate the cents part by subtracting the integer part from the original amount
        double cents = amount - Math.Floor(amount);
        return Math.Round(cents, 3); // Round to 3 decimal places for precision
    }
}

Imagine you're working on a financial application where precision is key. You're tasked with writing a method that takes a floating-point number representing a monetary value and extracts just the cents part of that amount. For example, if you have $123.456, you want to isolate and return the 0.456 part. How would you design a method in C# to accomplish this, ensuring that all necessary packages are included at the beginning of your code snippet?

Please use C# to implement the complete code without the Main function. Please follow the following type definitions:

```csharp
using xxx
...
class FinancialUtility
{
public class FinancialUtility
    {
        // Implement your code here.
    }
}
```


import java.util.Arrays;
public class AverageCalculator {
    public static double calculateAverage(int[] numbers) {
        if (numbers == null || numbers.length == 0) {
            throw new IllegalArgumentException("数组不能为空");
        }
        return Arrays.stream(numbers).average().orElse(Double.NaN);
    }
    public static void main(String[] args) {
        int[] testData = {1, 2, 3, 4, 5};
        double average = calculateAverage(testData);
        System.out.println("平均值为: " + average);
        check(calculateAverage(new int[]{10, 20, 30}), 20.0);
        check(calculateAverage(new int[]{5, 5, 5, 5}), 5.0);
        check(calculateAverage(new int[]{1, -1, 3, -3, 5, -5}), 0.0);
    }
    private static void check(double actual, double expected) {
        if (Math.abs(actual - expected) < 0.0001) {
            System.out.println("测试通过");
        } else {
            System.out.println("测试失败: 期望 " + expected + ", 实际 " + actual);
        }
    }
}

Write a Java program to calculate the average of a set of data. Make sure your program can accept an integer array as input and return the average of the set of data. Implement a method named `calculateAverage` which accepts an `int[]` type parameter and returns a `double` type result representing the average of the input array.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.Arrays;
public class AverageCalculator {
    public static double calculateAverage(int[] numbers) {
    }
}
```

Question: Write a piece of python code to achieve the following function.
Find the maximum perfect square number that is less than the nth Fibonacci number.
The function's name is max_square_number, and the input is an integer n.

Answer:
```python
def max_square_number(n):
 if n <= 2:
 return 0 # For the first two numbers in the Fibonacci sequence, no complete square numbers can be used.

 fibs = [0, 1] # Store the first two numbers of the Fibonacci sequence
 squares = [] # Store the list of perfect square numbers

 max_square = 0
 i = 2

 while i <= n:
 fibs.append(fibs[i-1] + fibs[i-2]) # Calculate the next Fibonacci number
 i += 1

 fib = fibs[-1]
 perfect_squares = [i**2 for i in range(1, int(math.sqrt(fib)) + 1)]
 max_square = max(filter(lambda x: x < fib, perfect_squares))
 return max_square
```

----------------

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class AverageCalculatorTest {
    @Test
    public void testCalculateAverage_withValidInput() {
        int[] numbers = {1, 2, 3, 4, 5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(3.0, result, 0.0001);
    }
    @Test
    public void testCalculateAverage_withNegativeNumbers() {
        int[] numbers = {1, -1, 3, -3, 5, -5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(0.0, result, 0.0001);
    }
    @Test
    public void testCalculateAverage_withEmptyArray() {
        int[] numbers = {};
        assertThrows(IllegalArgumentException.class, () -> {
            AverageCalculator.calculateAverage(numbers);
        });
    }
    @Test
    public void testCalculateAverage_withNullArray() {
        assertThrows(IllegalArgumentException.class, () -> {
            AverageCalculator.calculateAverage(null);
        });
    }
    @Test
    public void testCalculateAverage_withSameNumbers() {
        int[] numbers = {5, 5, 5, 5};
        double result = AverageCalculator.calculateAverage(numbers);
        assertEquals(5.0, result, 0.0001);
    }
}


import java.util.ArrayList;
import java.util.List;
class StudentDTO {
    private Long id;
    private String name;
    private List<Long> courseIds;
    public StudentDTO(Long id, String name, List<Long> courseIds) {
        this.id = id;
        this.name = name;
        this.courseIds = courseIds;
    }
    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public List<Long> getCourseIds() {
        return courseIds;
    }
}
class Course {
    private Long courseId;
    public Course(Long courseId) {
        this.courseId = courseId;
    }
    public void setCourseId(Long courseId) {
        this.courseId = courseId;
    }
    public Long getCourseId() {
        return courseId;
    }
}
class Student {
    private Long id;
    private String name;
    private List<Course> courses;
    public Student(Long id, String name, List<Course> courses) {
        this.id = id;
        this.name = name;
        this.courses = courses;
    }
    public Long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public List<Course> getCourses() {
        return courses;
    }
}
public class DTOToEntityConverter {
    public static Student toStudent(StudentDTO studentDTO) {
        List<Course> courses = new ArrayList<>();
        List<Long> courseIds = studentDTO.getCourseIds();
        if (courseIds != null) {
            for (Long courseId : courseIds) {
                Course course = new Course(courseId);
                courses.add(course);
            }
        }
        return new Student(studentDTO.getId(), studentDTO.getName(), courses);
    }
    public static void main(String[] args) {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        Student student = toStudent(studentDTO);
        System.out.println("学生ID: " + student.getId() + ", 名字: " + student.getName() + ", 课程数量: " + student.getCourses().size());
    }
}

Please write a Java function that can convert a Student Data Transfer Object (DTO) into a Student entity object. The Student DTO contains basic information about the student and a list of IDs for the courses they selected. The Student entity object, in addition to basic information, also needs to contain a list of Course entity objects. The Course entity object only includes the course ID. Note that if the course ID list is empty, the list of courses in the Student entity object should also be empty.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.ArrayList;
import java.util.List;
class StudentDTO {
    private Long id;
    private String name;
    private List<Long> courseIds;
    public StudentDTO(Long id, String name, List<Long> courseIds) {
    }
    public Long getId() {
    }
    public String getName() {
    }
    public List<Long> getCourseIds() {
    }
}
class Course {
    private Long courseId;
    public Course(Long courseId) {
    }
    public void setCourseId(Long courseId) {
    }
    public Long getCourseId() {
    }
}
class Student {
    private Long id;
    private String name;
    private List<Course> courses;
    public Student(Long id, String name, List<Course> courses) {
    }
    public Long getId() {
    }
    public String getName() {
    }
    public List<Course> getCourses() {
    }
}
public class DTOToEntityConverter {
    public static Student toStudent(StudentDTO studentDTO) {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
class StudentDTOTest {
    @Test
    void testGetId() {
        List<Long> courseIds = new ArrayList<>();
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals(1L, studentDTO.getId());
    }
    @Test
    void testGetName() {
        List<Long> courseIds = new ArrayList<>();
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals("张三", studentDTO.getName());
    }
    @Test
    void testGetCourseIds() {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        assertEquals(2, studentDTO.getCourseIds().size());
        assertTrue(studentDTO.getCourseIds().contains(101L));
        assertTrue(studentDTO.getCourseIds().contains(102L));
    }
}
class CourseTest {
    @Test
    void testGetCourseId() {
        Course course = new Course(101L);
        assertEquals(101L, course.getCourseId());
    }
    @Test
    void testSetCourseId() {
        Course course = new Course(101L);
        course.setCourseId(102L);
        assertEquals(102L, course.getCourseId());
    }
}
class StudentTest {
    @Test
    void testGetId() {
        List<Course> courses = new ArrayList<>();
        Student student = new Student(1L, "张三", courses);
        assertEquals(1L, student.getId());
    }
    @Test
    void testGetName() {
        List<Course> courses = new ArrayList<>();
        Student student = new Student(1L, "张三", courses);
        assertEquals("张三", student.getName());
    }
    @Test
    void testGetCourses() {
        List<Course> courses = new ArrayList<>();
        courses.add(new Course(101L));
        courses.add(new Course(102L));
        Student student = new Student(1L, "张三", courses);
        assertEquals(2, student.getCourses().size());
        assertEquals(101L, student.getCourses().get(0).getCourseId());
        assertEquals(102L, student.getCourses().get(1).getCourseId());
    }
}
class DTOToEntityConverterTest {
    @Test
    void testToStudent() {
        List<Long> courseIds = new ArrayList<>();
        courseIds.add(101L);
        courseIds.add(102L);
        StudentDTO studentDTO = new StudentDTO(1L, "张三", courseIds);
        Student student = DTOToEntityConverter.toStudent(studentDTO);
        assertNotNull(student);
        assertEquals(1L, student.getId());
        assertEquals("张三", student.getName());
        assertEquals(2, student.getCourses().size());
        assertEquals(101L, student.getCourses().get(0).getCourseId());
        assertEquals(102L, student.getCourses().get(1).getCourseId());
    }
}


import java.util.ArrayList;
public class SimpleTextEditor {
    private ArrayList<String> textHistory = new ArrayList<>();
    private String currentText = "";
    public void addText(String text) {
        textHistory.add(currentText);
        currentText += text;
    }
    public void undo() {
        if (!textHistory.isEmpty()) {
            currentText = textHistory.remove(textHistory.size() - 1);
        }
    }
    public String getText() {
        return currentText;
    }
    public static void main(String[] args) {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        System.out.println(editor.getText());
        editor.undo();
        System.out.println(editor.getText());
        editor.undo();
        System.out.println(editor.getText());
    }
}

Please write a Java program to implement the undo functionality for a simple text editor. This text editor only supports adding text and undo operations. The specific requirements are as follows:

- The editor is initially empty.
- Provide a method `addText` that accepts a string parameter and appends it to the existing text in the editor.
- Provide a method `undo` to undo the most recent `addText` operation.
- Provide a method `getText` to return the current text content of the editor.
- Use `ArrayList<String>` to store each added text to support undo operations.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.ArrayList;
public class SimpleTextEditor {
    private ArrayList<String> textHistory = new ArrayList<>();
    private String currentText = "";
    public void addText(String text) {
    }
    public void undo() {
    }
    public String getText() {
    }
}
```

import org.junit.Test;
import static org.junit.Assert.*;
public class SimpleTextEditorTest {
    @Test
    public void testAddText() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        assertEquals("Hello", editor.getText());
    }
    @Test
    public void testAddTextMultipleTimes() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        assertEquals("Hello, World!", editor.getText());
    }
    @Test
    public void testUndo() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        editor.undo();
        assertEquals("Hello", editor.getText());
    }
    @Test
    public void testUndoMultipleTimes() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.addText("Hello");
        editor.addText(", World!");
        editor.undo();
        editor.undo();
        assertEquals("", editor.getText());
    }
    @Test
    public void testUndoEmptyHistory() {
        SimpleTextEditor editor = new SimpleTextEditor();
        editor.undo();
        assertEquals("", editor.getText());
    }
}


import java.util.HashMap;
import java.util.Map;
class Book {
    String title;
    String author;
    int year;
    public Book(String title, String author, int year) {
        this.title = title;
        this.author = author;
        this.year = year;
    }
    @Override
    public String toString() {
        return "书名: " + title + ", 作者: " + author + ", 出版年份: " + year;
    }
}
public class LibrarySystem {
    private Map<Integer, Book> bookDatabase;
    public LibrarySystem() {
        bookDatabase = new HashMap<>();
        bookDatabase.put(1, new Book("Java编程思想", "Bruce Eckel", 2006));
        bookDatabase.put(2, new Book("Effective Java", "Joshua Bloch", 2008));
        bookDatabase.put(3, new Book("深入理解Java虚拟机", "周志明", 2013));
    }
    public String findBookDetails(int bookId) {
        if (bookDatabase.containsKey(bookId)) {
            return bookDatabase.get(bookId).toString();
        } else {
            return "抱歉，找不到ID为 " + bookId + " 的图书。";
        }
    }
    public static void main(String[] args) {
        LibrarySystem library = new LibrarySystem();
        System.out.println(library.findBookDetails(1));
        System.out.println(library.findBookDetails(4));
    }
}

Please write a Java program to simulate a book query function in a library system. This function should allow users to query detailed information about a book based on its ID, including the title, author, and publication year. Ensure that your code can handle exceptions; for instance, if the given book ID does not exist, it should return a user-friendly error message.
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
class Book {
    String title;
    String author;
    int year;
    public Book(String title, String author, int year) {
    }
    @Override
    public String toString() {
    }
}
public class LibrarySystem {
    private Map<Integer, Book> bookDatabase;
    public LibrarySystem() {
    }
    public String findBookDetails(int bookId) {
    }
}
```

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class LibrarySystemTest {
    private LibrarySystem library;
    @Before
    public void setUp() {
        library = new LibrarySystem();
    }
    @Test
    public void testFindBookDetails_ValidID() {
        String expected = "书名: Java编程思想, 作者: Bruce Eckel, 出版年份: 2006";
        String actual = library.findBookDetails(1);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_InvalidID() {
        String expected = "抱歉，找不到ID为 4 的图书。";
        String actual = library.findBookDetails(4);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_AnotherValidID() {
        String expected = "书名: Effective Java, 作者: Joshua Bloch, 出版年份: 2008";
        String actual = library.findBookDetails(2);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_YetAnotherValidID() {
        String expected = "书名: 深入理解Java虚拟机, 作者: 周志明, 出版年份: 2013";
        String actual = library.findBookDetails(3);
        assertEquals(expected, actual);
    }
    @Test
    public void testFindBookDetails_DifferentInvalidID() {
        String expected = "抱歉，找不到ID为 5 的图书。";
        String actual = library.findBookDetails(5);
        assertEquals(expected, actual);
    }
}


import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private static Map<Long, String> bookDatabase = new HashMap<>();
    static {
        bookDatabase.put(1L, "张三");
        bookDatabase.put(2L, "李四");
    }
    public static String fetchAuthorName(Long bookId) {
        String authorName = bookDatabase.get(bookId);
        if (authorName == null) {
            return "图书ID不存在";
        }
        return authorName;
    }
    public static void checkFunction() {
        System.out.println(fetchAuthorName(1L).equals("张三") ? "测试1通过" : "测试1失败");
        System.out.println(fetchAuthorName(2L).equals("李四") ? "测试2通过" : "测试2失败");
        System.out.println(fetchAuthorName(3L).equals("图书ID不存在") ? "测试3通过" : "测试3失败");
    }
    public static void main(String[] args) {
        checkFunction();
    }
}

Please write a Java function that retrieves the author name of a specified book from a simple book management system. Assume we have a `Book` class that includes the book's ID (`bookId`) and the author's name (`authorName`). You need to implement a function named `fetchAuthorName` that takes a book ID as a parameter and returns the corresponding book's author name. If the book ID does not exist, return a clear prompt string such as "Book ID does not exist."
Please use Java to implement the complete code without the Main function. Please follow the following type definitions:

```java
import java.util.HashMap;
import java.util.Map;
public class BookManager {
    private static Map<Long, String> bookDatabase = new HashMap<>();
    static {
    }
    public static String fetchAuthorName(Long bookId) {
    }
    public static void checkFunction() {
    }
}
```

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BookManagerTest {
    @Test
    public void testFetchAuthorName_ValidBookId1() {
        String result = BookManager.fetchAuthorName(1L);
        assertEquals("张三", result);
    }
    @Test
    public void testFetchAuthorName_ValidBookId2() {
        String result = BookManager.fetchAuthorName(2L);
        assertEquals("李四", result);
    }
    @Test
    public void testFetchAuthorName_InvalidBookId() {
        String result = BookManager.fetchAuthorName(3L);
        assertEquals("图书ID不存在", result);
    }
    @Test
    public void testFetchAuthorName_NullBookId() {
        String result = BookManager.fetchAuthorName(null);
        assertEquals("图书ID不存在", result);
    }
    @Test
    public void testFetchAuthorName_DifferentInvalidBookId() {
        String result = BookManager.fetchAuthorName(99L);
        assertEquals("图书ID不存在", result);
    }
}