Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 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. using System.IO;
  7.  
  8. namespace ConsoleApp16
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. List<string> names = new List<string>();
  16. List<string> surnames = new List<string>();
  17. List<int> salaries = new List<int>();
  18. List<int> age = new List<int>();
  19.  
  20. string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
  21. List<string> contents = File.ReadAllLines(path).ToList();
  22.  
  23.  
  24. for (int i = 0; i < contents.Count; i++)
  25. {
  26. string[] p = contents[i].Split(';');
  27. names.Add(p[0]);
  28. surnames.Add(p[1]);
  29. salaries.Add(Convert.ToInt32(p[2]));
  30. age.Add(Convert.ToInt32(p[3]));
  31. }
  32.  
  33.  
  34. //for (int i = 0; i < names.Count; i++)
  35. //{
  36. // if(salaries[i]>30000)
  37. // {
  38. // Console.WriteLine(names[i]);
  39. // }
  40. //}
  41.  
  42. for (int i = 0; i < names.Count; i++)
  43. {
  44. if (salaries[i] < 600000)
  45. {
  46. salaries[i] = salaries[i] * 25 / 100 + salaries[i];
  47. }
  48. }
  49.  
  50. List<string> outlist = new List<string>();
  51. for (int i = 0; i < names.Count; i++)
  52. {
  53. string content = string.Join(";", names[i], surnames[i], salaries[i], age[i]);
  54. outlist.Add(content);
  55. }
  56.  
  57. File.WriteAllLines(path, outlist);
  58.  
  59.  
  60.  
  61.  
  62. // string str = "hector;eneida;panagiotis;mitsos";
  63. //str = str.Replace(';', ' ');
  64. // Console.WriteLine(str);
  65.  
  66. // ReadPersons();
  67.  
  68. }
  69.  
  70.  
  71. public static void ReadPersons()
  72. {
  73. string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
  74.  
  75. string[] p = File.ReadAllLines(path);
  76.  
  77. for (int i = 0; i < p.Length; i++)
  78. {
  79. p[i] = p[i].Replace(';', ' ');
  80. }
  81.  
  82.  
  83.  
  84. foreach (var item in p)
  85. {
  86. Console.WriteLine(item);
  87. }
  88.  
  89. }
  90.  
  91. public static void ReadAllEmployees()
  92. {
  93.  
  94. }
  95.  
  96.  
  97.  
  98. public static void AddPerson()
  99. {
  100.  
  101. //List<string> names = new List<string>() { "Hector", "Basilis", "Mixalis" };
  102. //List<string> surnames = new List<string>() { "Gatsos", "Paspas", "Taspsa" };
  103. //List<string> salaries = new List<string>() { "50000", "3000", "4000" };
  104. //List<string> ages = new List<string>() { "33", "9", "65" };
  105. //List<string> content = new List<string>();
  106.  
  107.  
  108.  
  109. string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
  110. Console.WriteLine("Dose onoma");
  111. string name = Console.ReadLine();
  112.  
  113. Console.WriteLine("Dose epitheto");
  114. string epitheto = Console.ReadLine();
  115.  
  116. Console.WriteLine("Dose salary");
  117. string salary = Console.ReadLine();
  118.  
  119. Console.WriteLine("Dose age");
  120. string age = Console.ReadLine();
  121.  
  122. var content = string.Join(",", name, epitheto, salary, age);
  123. List<string> contents = new List<string>();
  124. contents.Add(content);
  125. //content = content + Environment.NewLine;
  126. File.AppendAllLines(path, contents);
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. // https://pastebin.com/AUejUNg6
  136.  
  137.  
  138.  
  139.  
  140. //pastebin.com/qXNKAMWs
  141.  
  142.  
  143. }
  144.  
  145.  
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement