Advertisement
Guest User

Untitled

a guest
May 4th, 2015
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CategorizeNum_3
  8. {
  9.     class CategorizeNum_3
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             double[] numbers = input.Split().Select(double.Parse).ToArray();
  15.             List<double> roundNum = new List<double>();
  16.             List<double> zeroFractNum = new List<double>();
  17.  
  18.             for (int a = 0; a < numbers.Length; a++)
  19.             {
  20.                 if (numbers[a] % 1 != 0)
  21.                 {
  22.                     zeroFractNum.Add(numbers[a]);
  23.                 }
  24.                 else
  25.                 {
  26.                     roundNum.Add(numbers[a]);
  27.                 }
  28.             }
  29.             Console.WriteLine("Non - Zero Fraction Numbers");
  30.             zeroFractNum.ForEach(a => Console.Write(a + " "));
  31.             Console.WriteLine("min -- {0}",zeroFractNum.Min());
  32.             Console.WriteLine("max -- {0}", zeroFractNum.Max());
  33.             Console.WriteLine("sum -- {0}", zeroFractNum.Sum());
  34.             Console.WriteLine("average -- {0:f2}",zeroFractNum.Average());
  35.             Console.WriteLine("Round Numbers");
  36.             roundNum.ForEach(b => Console.Write(b + " "));
  37.             Console.WriteLine("min -- {0}",roundNum.Min());
  38.             Console.WriteLine("max -- {0}",roundNum.Max());
  39.             Console.WriteLine("sum -- {0}",roundNum.Sum());
  40.             Console.WriteLine("average -- {0:f2}",roundNum.Average());
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement