Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Exercise7GreatestOf5Variables
- {
- static void Main()
- {
- decimal result = decimal.MinValue;
- decimal[] input = new decimal[5];
- for (int i = 0; i < 5; i++)
- {
- bool checkInput = false;
- while (!checkInput)
- {
- Console.Write("\nPlease input number N{0}: ", i + 1);
- checkInput = decimal.TryParse(Console.ReadLine(), out input[i]);
- if (checkInput)
- {
- continue;
- }
- Console.WriteLine("\nWrong input data, try again!");
- }
- }
- for (int i = 0; i < 5; i++)
- {
- if (input[i] > result)
- {
- result = input[i];
- }
- }
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement