Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp9.CurrencyConverter
- {
- class Program
- {
- static void Main(string[] args)
- {
- double ruble;
- double dollar;
- double euro;
- double priceDollar = 63.95;
- double priceEuro = 70.86;
- double wantBuyValue;
- int firstCurrencySelect = 1;
- int secondCurrencySelect;
- string changeCurrency = "\nВыберите валюту, в которую будем переводить: \n";
- string errorLowMonye = "\nНельзя совершить данную операцию. Не хватает денег\n";
- string errorRightNumber = "Пожалуйста введите корректный номер команды\n";
- Console.WriteLine("Введите, какое у вас кол-во рублей, долларов и евро:");
- ruble = Convert.ToDouble(Console.ReadLine());
- dollar = Convert.ToDouble(Console.ReadLine());
- euro = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("\nДальнейшее управление программой осуществляется числовым вводом. Первая цифра строчки означает команду операции.\n");
- while (firstCurrencySelect != 0)
- {
- Console.WriteLine("Выберите валюту, которую хотите перевести:\n\n1. Рубли.\n2. Доллары. \n3. Евро. \n0. Выход из программы.");
- firstCurrencySelect = Convert.ToInt32(Console.ReadLine());
- if (firstCurrencySelect == 1)
- {
- Console.WriteLine(changeCurrency + "\n1.Доллары \n2.Евро");
- secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
- }
- else if (firstCurrencySelect == 2)
- {
- Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Евро");
- secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
- }
- else if (firstCurrencySelect == 3)
- {
- Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Доллары");
- secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
- }
- else if (firstCurrencySelect == 0)
- {
- break;
- }
- else
- {
- Console.WriteLine(errorRightNumber);
- Console.ReadLine();
- continue;
- }
- Console.WriteLine("\nКакую сумму вы желаете получить?\n");
- wantBuyValue = Convert.ToDouble(Console.ReadLine());
- if (firstCurrencySelect == 1)
- {
- if (secondCurrencySelect == 1)
- {
- if (wantBuyValue * priceDollar < ruble)
- {
- dollar += wantBuyValue;
- ruble -= priceDollar * wantBuyValue;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else if (secondCurrencySelect == 2)
- {
- if (wantBuyValue * priceEuro < ruble)
- {
- euro += wantBuyValue;
- ruble -= priceEuro * wantBuyValue;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine(errorRightNumber);
- Console.ReadLine();
- }
- }
- else if (firstCurrencySelect == 2)
- {
- if (secondCurrencySelect == 1)
- {
- if (wantBuyValue / priceDollar < dollar)
- {
- dollar -= wantBuyValue / priceDollar;
- ruble += wantBuyValue;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else if (secondCurrencySelect == 2)
- {
- if ((wantBuyValue * priceDollar) / priceEuro < dollar)
- {
- euro += wantBuyValue;
- dollar -= (wantBuyValue * priceDollar) / priceEuro;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine(errorRightNumber);
- Console.ReadLine();
- }
- }
- else if (firstCurrencySelect == 3)
- {
- Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Доллары");
- secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
- if (secondCurrencySelect == 1)
- {
- if (wantBuyValue / priceEuro < euro)
- {
- euro -= wantBuyValue / priceEuro;
- ruble += wantBuyValue;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else if (secondCurrencySelect == 2)
- {
- if ((wantBuyValue * priceEuro) / priceDollar < euro)
- {
- dollar += wantBuyValue;
- euro -= (wantBuyValue * priceEuro) / priceDollar;
- }
- else
- {
- Console.WriteLine(errorLowMonye);
- Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine(errorRightNumber);
- Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine(errorRightNumber);
- Console.ReadLine();
- }
- Console.WriteLine($"\nТеперь у вас {ruble} рублей, {dollar} долларов и {euro} евро. \n");
- }
- Console.WriteLine("\nДо свидания.");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement