Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FindTheGreatestOutOf5Nums
- {
- static void Main()
- {
- //Write a program that finds the greatest of given 5 variables.
- Console.Write("Please enter the first real number:");
- decimal firstNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the second real number:");
- decimal secondNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the third real number:");
- decimal thirdNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the fourth ot real number:");
- decimal fourthNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the fifth real number:");
- decimal fifthNum = decimal.Parse(Console.ReadLine());
- decimal biggestNum = decimal.MinValue;
- if (firstNum > biggestNum)
- {
- biggestNum = firstNum;
- }
- if (secondNum > biggestNum)
- {
- biggestNum = secondNum;
- }
- if (thirdNum > biggestNum)
- {
- biggestNum = thirdNum;
- }
- if (fourthNum > biggestNum)
- {
- biggestNum = fourthNum;
- }
- if (fifthNum > biggestNum)
- {
- biggestNum = fifthNum;
- }
- Console.WriteLine("The biggest number is {0}", biggestNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement