Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MoneyManager
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] txtInfo = File.ReadAllLines(@"C:\Users\mL\Desktop\Money Manager by miroLLL\Months\January.txt");
- string lastValueLine = txtInfo[txtInfo.Length - 2];
- string[] lastValueLineSplit = lastValueLine.Split(' ');
- decimal amount = decimal.Parse(lastValueLineSplit[3]);
- DateTime now = DateTime.Now;
- string path = @"c:\users\ml\desktop\money manager by mirolll\months\January.txt";
- string log = @"c:\users\ml\desktop\money manager by mirolll\months\JanuaryLog.txt";
- string separate = new string('-', 50);
- //---------------------------------------------------------------------------------------------
- Console.WriteLine("Hello, Money Manager by MiroLLL's User, how can i help you?\n");
- Console.WriteLine("1: I want to enter some expenses to my expense list.");
- Console.WriteLine("2: I want to add a few bucks to my amount.");
- Console.WriteLine(separate);
- Console.WriteLine("Please press the number of your chouse 1/2?: ");
- Console.WriteLine("---");
- string userChoice = Console.ReadLine();
- if (userChoice == "1")
- {
- Console.WriteLine(separate);
- Console.WriteLine("How many total purchases do you have for the day?");
- int totalPurchases = int.Parse(Console.ReadLine());
- Console.WriteLine("---");
- decimal[] expenses = new decimal[totalPurchases];
- string[] expensesType = new string[totalPurchases];
- for (int i = 0; i < totalPurchases; i++)
- {
- Console.Write("Expense - ");
- expenses[i] = decimal.Parse(Console.ReadLine());
- Console.Write("Where they are spend and for what? - ");
- expensesType[i] = Console.ReadLine();
- Console.WriteLine(separate);
- }
- decimal expensesForTheDay = 0;
- for (int i = 0; i < expenses.Length; i++)
- {
- expensesForTheDay += expenses[i];
- }
- decimal moneyleft = amount - expensesForTheDay;
- using (StreamWriter sw = File.AppendText(path))
- {
- sw.WriteLine("On date {0}", now);
- sw.WriteLine("Amount was equal to {0} lv.", amount);
- for (int i = 0; i < totalPurchases; i++)
- {
- sw.WriteLine("{0} lv for {1}.", expenses[i], expensesType[i]);
- }
- sw.WriteLine("Money left - {0} lv", moneyleft);
- sw.WriteLine(separate);
- amount = moneyleft;
- }
- }
- else if (userChoice == "2")
- {
- Console.Write("What amount will you add to the available up to now? - ");
- decimal addMoney = decimal.Parse(Console.ReadLine());
- amount += addMoney;
- using (StreamWriter sw = File.AppendText(log))
- {
- sw.WriteLine("On date {0} you add {1} lv to your amount", now, addMoney);
- sw.WriteLine("Amount = {0} lv", amount);
- sw.WriteLine(separate);
- }
- }
- else
- {
- Console.WriteLine("please choose between 1 and 2...");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement