Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace TelephoneNetSubscribers
- {
- public class TelephoneNetSubscribers
- {
- public string LastName { get; set; }
- public string PhoneNumber { get; set; }
- public double ConversationDuration { get; set; }
- public TelephoneNetSubscribers() { }
- public TelephoneNetSubscribers(string _lastName, string _phoneNumber, double _conversationDuration)
- {
- LastName = _lastName;
- PhoneNumber = _phoneNumber;
- ConversationDuration = _conversationDuration;
- }
- }
- class Program
- {
- static void Input(List<TelephoneNetSubscribers> l, uint count)
- {
- for (int i = 0; i < count; i++)
- {
- Console.Write("Введiть прiзвище: ");
- string LastName = Console.ReadLine();
- Console.Write("Введiть номер телефона: ");
- string PhoneNumber = Console.ReadLine();
- Console.Write("Введiть тривалiсть розмови: ");
- double ConversationDuration = double.Parse(Console.ReadLine());
- TelephoneNetSubscribers t = new TelephoneNetSubscribers(LastName, PhoneNumber, ConversationDuration);
- l.Add(t);
- Console.WriteLine();
- }
- }
- static void GetList(List<TelephoneNetSubscribers> l)
- {
- foreach (var i in l)
- Console.WriteLine($"Прiзвище: { i.LastName}. Номер телефона: {i.PhoneNumber}. Тривалiсть розмови: {i.ConversationDuration}\n");
- }
- static void GetListByDurationConversation(List<TelephoneNetSubscribers> l, uint n)
- {
- foreach (var i in l)
- {
- if(i.ConversationDuration > n)
- Console.WriteLine($"Прiзвище: { i.LastName}. Номер телефона: {i.PhoneNumber}. Тривалiсть розмови: {i.ConversationDuration}\n");
- }
- }
- static void Main()
- {
- List<TelephoneNetSubscribers> l = new List<TelephoneNetSubscribers>();
- Console.Write("Введiть кiлькiсть абонентiв: ");
- uint count = uint.Parse(Console.ReadLine());
- Input(l, count);
- Console.WriteLine("\nДанi про всiх абонентів:");
- GetList(l);
- Console.WriteLine("\nДанi про абонентiв, тривалiсть розмов яких перевищує n годин:");
- Console.Write("Введiть n: ");
- uint n = uint.Parse(Console.ReadLine());
- GetListByDurationConversation(l, n);
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment