Question: Using C#, implement a method GetMax() with two integer (int) parameters, that returns maximal of the two numbers. Write a program that reads three numbers

Using C#, implement a method GetMax() with two integer (int) parameters, that returns maximal of the two numbers. Write a program that reads three numbers from the console and prints the biggest of them. Use the GetMax() method you just implemented. Write a test program that validates that the methods works correctly. Guideline: Use the expression Max(a, b, c) = Max(Max(a, b), c). To test the code check whether the results from the invoked methods is correct for a set of examples that cover the most interesting cases, e.g. Max(1,2)=2; Max(3,-1)=3; Max(-1,-1)=-1; Max(1,2,444444)=444444; Max(5,2,1)=5; Max(-1,6,5)=6; Max(0,0,0)=0; Max(-10,-10,-10)=-10; Max(2000000000,-2000000001,2000000002)=2000000002; etc. You may write a generic method that works not just for int but for any other type T using the following declaration: static T Max(T a, T b) where T : IComparable { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!