Advertisement
sylviapsh

The Greatest Out Of 5 Numbers

Dec 28th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. class FindTheGreatestOutOf5Nums
  3. {
  4.   static void Main()
  5.   {
  6.     //Write a program that finds the greatest of given 5 variables.
  7.  
  8.     Console.Write("Please enter the first real number:");
  9.     decimal firstNum = decimal.Parse(Console.ReadLine());
  10.     Console.Write("Please enter the second real number:");
  11.     decimal secondNum = decimal.Parse(Console.ReadLine());
  12.     Console.Write("Please enter the third real number:");
  13.     decimal thirdNum = decimal.Parse(Console.ReadLine());
  14.     Console.Write("Please enter the fourth ot real number:");
  15.     decimal fourthNum = decimal.Parse(Console.ReadLine());
  16.     Console.Write("Please enter the fifth real number:");
  17.     decimal fifthNum = decimal.Parse(Console.ReadLine());
  18.  
  19.     decimal biggestNum = decimal.MinValue;
  20.  
  21.     if (firstNum > biggestNum)
  22.     {
  23.       biggestNum = firstNum;
  24.     }
  25.     if (secondNum > biggestNum)
  26.     {
  27.       biggestNum = secondNum;
  28.     }
  29.     if (thirdNum > biggestNum)
  30.     {
  31.       biggestNum = thirdNum;
  32.     }
  33.     if (fourthNum > biggestNum)
  34.     {
  35.       biggestNum = fourthNum;
  36.     }
  37.     if (fifthNum > biggestNum)
  38.     {
  39.       biggestNum = fifthNum;
  40.     }
  41.  
  42.     Console.WriteLine("The biggest number is {0}", biggestNum);
  43.   }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement