SHARE
TWEET

Exercise7GreatestOf5Variables

g-stoyanov Nov 30th, 2012 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class Exercise7GreatestOf5Variables
  4. {
  5.     static void Main()
  6.     {
  7.         decimal result = decimal.MinValue;
  8.         decimal[] input = new decimal[5];
  9.         for (int i = 0; i < 5; i++)
  10.         {
  11.             bool checkInput = false;
  12.             while (!checkInput)
  13.             {
  14.                 Console.Write("\nPlease input number N{0}: ", i + 1);
  15.                 checkInput = decimal.TryParse(Console.ReadLine(), out input[i]);
  16.                 if (checkInput)
  17.                 {
  18.                     continue;
  19.                 }
  20.                 Console.WriteLine("\nWrong input data, try again!");
  21.             }
  22.         }
  23.         for (int i = 0; i < 5; i++)
  24.         {
  25.             if (input[i] > result)
  26.             {
  27.                 result = input[i];
  28.             }
  29.         }
  30.         Console.WriteLine("\n\nBiggest number of set {0}, {1}, {2}, {3}, {4} is {5}!\n", input[0], input[1], input[2], input[3], input[4], result);
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top