Advertisement
miroLLL

MM

Feb 6th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace MoneyManager
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string[] txtInfo = File.ReadAllLines(@"C:\Users\mL\Desktop\Money Manager by miroLLL\Months\January.txt");
  15.             string lastValueLine = txtInfo[txtInfo.Length - 2];
  16.             string[] lastValueLineSplit = lastValueLine.Split(' ');
  17.  
  18.             decimal amount = decimal.Parse(lastValueLineSplit[3]);
  19.  
  20.             DateTime now = DateTime.Now;
  21.  
  22.             string path = @"c:\users\ml\desktop\money manager by mirolll\months\January.txt";
  23.             string log = @"c:\users\ml\desktop\money manager by mirolll\months\JanuaryLog.txt";
  24.  
  25.  
  26.             string separate = new string('-', 50);
  27.             //---------------------------------------------------------------------------------------------
  28.  
  29.             Console.WriteLine("Hello, Money Manager by MiroLLL's User, how can i help you?\n");
  30.             Console.WriteLine("1: I want to enter some expenses to my expense list.");
  31.             Console.WriteLine("2: I want to add a few bucks to my amount.");
  32.             Console.WriteLine(separate);
  33.             Console.WriteLine("Please press the number of your chouse 1/2?: ");
  34.             Console.WriteLine("---");
  35.  
  36.             string userChoice = Console.ReadLine();
  37.  
  38.             if (userChoice == "1")
  39.             {
  40.                 Console.WriteLine(separate);
  41.                 Console.WriteLine("How many total purchases do you have for the day?");
  42.                 int totalPurchases = int.Parse(Console.ReadLine());
  43.                 Console.WriteLine("---");
  44.  
  45.                 decimal[] expenses = new decimal[totalPurchases];
  46.                 string[] expensesType = new string[totalPurchases];
  47.  
  48.                 for (int i = 0; i < totalPurchases; i++)
  49.                 {
  50.                     Console.Write("Expense - ");
  51.                     expenses[i] = decimal.Parse(Console.ReadLine());
  52.  
  53.                     Console.Write("Where they are spend and for what? - ");
  54.                     expensesType[i] = Console.ReadLine();
  55.                     Console.WriteLine(separate);
  56.                 }
  57.  
  58.                 decimal expensesForTheDay = 0;
  59.                 for (int i = 0; i < expenses.Length; i++)
  60.                 {
  61.                     expensesForTheDay += expenses[i];
  62.                 }
  63.  
  64.                 decimal moneyleft = amount - expensesForTheDay;
  65.  
  66.                 using (StreamWriter sw = File.AppendText(path))
  67.                 {
  68.                     sw.WriteLine("On date {0}", now);
  69.                     sw.WriteLine("Amount was equal to {0} lv.", amount);
  70.                     for (int i = 0; i < totalPurchases; i++)
  71.                     {
  72.                         sw.WriteLine("{0} lv for {1}.", expenses[i], expensesType[i]);
  73.                     }
  74.                     sw.WriteLine("Money left - {0} lv", moneyleft);
  75.  
  76.                     sw.WriteLine(separate);
  77.  
  78.                     amount = moneyleft;
  79.                 }
  80.             }
  81.             else if (userChoice == "2")
  82.             {
  83.                 Console.Write("What amount will you add to the available up to now? - ");
  84.                 decimal addMoney = decimal.Parse(Console.ReadLine());
  85.                 amount += addMoney;
  86.  
  87.                 using (StreamWriter sw = File.AppendText(log))
  88.                 {
  89.                     sw.WriteLine("On date {0} you add {1} lv to your amount", now, addMoney);
  90.                     sw.WriteLine("Amount = {0} lv", amount);
  91.                     sw.WriteLine(separate);
  92.                 }
  93.             }
  94.             else
  95.             {
  96.                 Console.WriteLine("please choose between 1 and 2...");
  97.             }
  98.         }
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement