Advertisement
ralka

Untitled

May 10th, 2016
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. //Create a method GetMax() with two integer (int) parameters, that returns maximal of the two numbers.
  2. //Write a program that reads three numbers from the console and prints the biggest of them.
  3. //Use the GetMax() method you just created
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace _29.Max_Method
  12. {
  13.     class MaxMethod
  14.     {
  15.         static void Main(string[] args)
  16.         {
  17.             int firstNumber = int.Parse(Console.ReadLine());
  18.             int secondNumber = int.Parse(Console.ReadLine());
  19.             int thirdNumber = int.Parse(Console.ReadLine());
  20.  
  21.             int firstMax = GetMax(firstNumber, secondNumber);
  22.             int max = GetMax(firstMax, thirdNumber);
  23.  
  24.             Console.WriteLine(max);
  25.         }
  26.  
  27.         static int GetMax(int num1, int num2)
  28.         {
  29.             if (num1 > num2)
  30.             {
  31.                 return num1;
  32.             }
  33.             return num2;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement