Vla_DOS

Untitled

Apr 4th, 2022 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace TelephoneNetSubscribers
  5. {
  6.     public class TelephoneNetSubscribers
  7.     {
  8.         public string LastName { get; set; }
  9.         public string PhoneNumber { get; set; }
  10.         public double ConversationDuration { get; set; }
  11.         public TelephoneNetSubscribers() { }
  12.         public TelephoneNetSubscribers(string _lastName, string _phoneNumber, double _conversationDuration)
  13.         {            
  14.             LastName = _lastName;
  15.             PhoneNumber = _phoneNumber;
  16.             ConversationDuration = _conversationDuration;
  17.         }
  18.     }
  19.     class Program
  20.     {
  21.         static void Input(List<TelephoneNetSubscribers> l, uint count)
  22.         {
  23.             for (int i = 0; i < count; i++)
  24.             {
  25.                 Console.Write("Введiть прiзвище: ");
  26.                 string LastName = Console.ReadLine();
  27.  
  28.                 Console.Write("Введiть номер телефона: ");
  29.                 string PhoneNumber = Console.ReadLine();
  30.  
  31.                 Console.Write("Введiть тривалiсть розмови: ");
  32.                 double ConversationDuration = double.Parse(Console.ReadLine());
  33.  
  34.                 TelephoneNetSubscribers t = new TelephoneNetSubscribers(LastName, PhoneNumber, ConversationDuration);
  35.                 l.Add(t);
  36.                 Console.WriteLine();
  37.             }
  38.         }
  39.         static void GetList(List<TelephoneNetSubscribers> l)
  40.         {
  41.             foreach (var i in l)
  42.                 Console.WriteLine($"Прiзвище: { i.LastName}. Номер телефона: {i.PhoneNumber}. Тривалiсть розмови: {i.ConversationDuration}\n");
  43.         }
  44.         static void GetListByDurationConversation(List<TelephoneNetSubscribers> l, uint n)
  45.         {
  46.             foreach (var i in l)
  47.             {
  48.                 if(i.ConversationDuration > n)
  49.                     Console.WriteLine($"Прiзвище: { i.LastName}. Номер телефона: {i.PhoneNumber}. Тривалiсть розмови: {i.ConversationDuration}\n");
  50.             }
  51.         }
  52.  
  53.         static void Main()
  54.         {
  55.             List<TelephoneNetSubscribers> l = new List<TelephoneNetSubscribers>();
  56.  
  57.             Console.Write("Введiть кiлькiсть абонентiв: ");
  58.             uint count = uint.Parse(Console.ReadLine());
  59.             Input(l, count);
  60.  
  61.             Console.WriteLine("\nДанi про всiх абонентів:");
  62.             GetList(l);
  63.  
  64.             Console.WriteLine("\nДанi про абонентiв, тривалiсть розмов яких перевищує n годин:");
  65.             Console.Write("Введiть n: ");
  66.             uint n = uint.Parse(Console.ReadLine());
  67.             GetListByDurationConversation(l, n);
  68.             Console.ReadLine();
  69.         }
  70.     }
  71. }
Add Comment
Please, Sign In to add comment