veronikaaa86

04 List Lab

Feb 12th, 2018
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 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 ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> numbers = Console.ReadLine()
  14.                .Split(new char[] { ',', '.', ';', ':', '!', ' ', '"', '\\', '/', '[', ']', '(', ')', '\'' })
  15.                .ToList();
  16.  
  17.             List<string> lowerCase = new List<string>();
  18.             List<string> mixedCase = new List<string>();
  19.             List<string> upperCase = new List<string>();
  20.  
  21.             foreach (var symbol in numbers)
  22.             {
  23.                 bool lower = false;
  24.                 bool mixed = false;
  25.                 bool upper = false;
  26.  
  27.                
  28.  
  29.                     foreach (char letter in symbol)
  30.                     {
  31.                     if (symbol != "" && symbol != " ")
  32.                     {
  33.                         if (letter >= 'a' && letter <= 'z')
  34.                         {
  35.                             lower = true;
  36.                         }
  37.                         else if (letter >= 'A' && letter <= 'Z')
  38.                         {
  39.                             upper = true;
  40.                         }
  41.                         else
  42.                         {
  43.                             mixed = true;
  44.                         }
  45.  
  46.                     }
  47.                 }
  48.  
  49.  
  50.  
  51.  
  52.                 if (symbol != "" && symbol != " ")
  53.                 {
  54.                     if (lower && !mixed && !upper)
  55.                     {
  56.                         lowerCase.Add(symbol);
  57.                     }
  58.  
  59.                     else if (!lower && !mixed && upper)
  60.                     {
  61.                         upperCase.Add(symbol);
  62.                     }
  63.                     else
  64.                     {
  65.                         mixedCase.Add(symbol);
  66.                     }
  67.                 }
  68.  
  69.             }
  70.  
  71.  
  72.             Console.WriteLine($"Lower-case: {string.Join(", ", lowerCase)}");
  73.             Console.WriteLine($"Mixed-case: {string.Join(", ", mixedCase)}");
  74.             Console.WriteLine($"Upper-case: {string.Join(", ", upperCase)}");
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment