Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp16
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> names = new List<string>();
- List<string> surnames = new List<string>();
- List<int> salaries = new List<int>();
- List<int> age = new List<int>();
- string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
- List<string> contents = File.ReadAllLines(path).ToList();
- for (int i = 0; i < contents.Count; i++)
- {
- string[] p = contents[i].Split(';');
- names.Add(p[0]);
- surnames.Add(p[1]);
- salaries.Add(Convert.ToInt32(p[2]));
- age.Add(Convert.ToInt32(p[3]));
- }
- //for (int i = 0; i < names.Count; i++)
- //{
- // if(salaries[i]>30000)
- // {
- // Console.WriteLine(names[i]);
- // }
- //}
- for (int i = 0; i < names.Count; i++)
- {
- if (salaries[i] < 600000)
- {
- salaries[i] = salaries[i] * 25 / 100 + salaries[i];
- }
- }
- List<string> outlist = new List<string>();
- for (int i = 0; i < names.Count; i++)
- {
- string content = string.Join(";", names[i], surnames[i], salaries[i], age[i]);
- outlist.Add(content);
- }
- File.WriteAllLines(path, outlist);
- // string str = "hector;eneida;panagiotis;mitsos";
- //str = str.Replace(';', ' ');
- // Console.WriteLine(str);
- // ReadPersons();
- }
- public static void ReadPersons()
- {
- string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
- string[] p = File.ReadAllLines(path);
- for (int i = 0; i < p.Length; i++)
- {
- p[i] = p[i].Replace(';', ' ');
- }
- foreach (var item in p)
- {
- Console.WriteLine(item);
- }
- }
- public static void ReadAllEmployees()
- {
- }
- public static void AddPerson()
- {
- //List<string> names = new List<string>() { "Hector", "Basilis", "Mixalis" };
- //List<string> surnames = new List<string>() { "Gatsos", "Paspas", "Taspsa" };
- //List<string> salaries = new List<string>() { "50000", "3000", "4000" };
- //List<string> ages = new List<string>() { "33", "9", "65" };
- //List<string> content = new List<string>();
- string path = @"C:\Users\pclab\Desktop\mitsos" + 2 + ".txt";
- Console.WriteLine("Dose onoma");
- string name = Console.ReadLine();
- Console.WriteLine("Dose epitheto");
- string epitheto = Console.ReadLine();
- Console.WriteLine("Dose salary");
- string salary = Console.ReadLine();
- Console.WriteLine("Dose age");
- string age = Console.ReadLine();
- var content = string.Join(",", name, epitheto, salary, age);
- List<string> contents = new List<string>();
- contents.Add(content);
- //content = content + Environment.NewLine;
- File.AppendAllLines(path, contents);
- // https://pastebin.com/AUejUNg6
- //pastebin.com/qXNKAMWs
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement