Advertisement
Guest User

Greater of Two Values

a guest
Oct 7th, 2017
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. internal class GraterOfTwoValues
  4. {
  5.     private static void Main()
  6.     {
  7.         string dataType = Console.ReadLine(); //doesn't need it
  8.  
  9.         string input1 = Console.ReadLine();
  10.         string input2 = Console.ReadLine();
  11.  
  12.         string max = GetMax(input1, input2);
  13.  
  14.         Console.WriteLine(max);
  15.     }
  16.  
  17.     private static string GetMax(string input1, string input2)
  18.     {
  19.         try
  20.         {
  21.             double num1 = double.Parse(input1);
  22.             double num2 = double.Parse(input2);
  23.  
  24.             return Math.Max(num1, num2).ToString();
  25.         }
  26.         catch (Exception)
  27.         {
  28.             if (input1.CompareTo(input2) >= 0)
  29.             {
  30.                 return input1;
  31.             }
  32.             else
  33.             {
  34.                 return input2;
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement