Last active
April 17, 2022 08:52
-
-
Save Mazday21/57f9309c395b86548ade1d9d198d49ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
double balanceCurrencyX = 200; | |
double balanceCurrencyY = 300; | |
double balanceCurrencyZ = 500; | |
double tempX; | |
double tempY; | |
double tempZ; | |
string tempCurrencyTo; | |
string tempCurrencyFrom; | |
int rateXtoY = 2; | |
int rateYtoZ = 4; | |
int rateXtoZ = rateXtoY * rateYtoZ; | |
string exitCicle = ""; | |
while (exitCicle != "exit") | |
{ | |
Console.WriteLine($"У Вас имеется {balanceCurrencyX} валюты Х, {balanceCurrencyY} валюты Y и {balanceCurrencyZ} валюты Z"); | |
Console.WriteLine($"Текущие курсы валют: {rateXtoY} Y стоит 1 Z, {rateYtoZ} Z стоит 1 Y и {rateXtoZ} Z стоит 1 X"); | |
Console.WriteLine("Введите название валюты, в которую хотите конвертировать"); | |
tempCurrencyTo = Console.ReadLine(); | |
Console.WriteLine("Введите название валюты, из которой хотите конвертировать"); | |
tempCurrencyFrom = Console.ReadLine(); | |
Console.WriteLine("Введите сумму валюты, в которую хотите конвертировать"); | |
if(tempCurrencyTo == "X") | |
{ | |
tempX = Convert.ToDouble(Console.ReadLine()); | |
balanceCurrencyX += tempX; | |
if(tempCurrencyFrom == "Y") | |
{ | |
balanceCurrencyY -= tempX * rateXtoY; | |
} | |
else if (tempCurrencyFrom == "Z") | |
{ | |
balanceCurrencyZ -= tempX * rateXtoZ; | |
} | |
} | |
else if (tempCurrencyTo == "Y") | |
{ | |
tempY = Convert.ToDouble(Console.ReadLine()); | |
balanceCurrencyY += tempY; | |
if (tempCurrencyFrom == "X") | |
{ | |
balanceCurrencyX -= tempY / rateXtoY; | |
} | |
else if (tempCurrencyFrom == "Z") | |
{ | |
balanceCurrencyZ -= tempY * rateYtoZ; | |
} | |
} | |
else if (tempCurrencyTo == "Z") | |
{ | |
tempZ = Convert.ToDouble(Console.ReadLine()); | |
balanceCurrencyZ += tempZ; | |
if (tempCurrencyFrom == "X") | |
{ | |
balanceCurrencyY -= tempZ / rateXtoZ; | |
} | |
else if (tempCurrencyFrom == "Y") | |
{ | |
balanceCurrencyZ -= tempZ / rateYtoZ; | |
} | |
} | |
Console.WriteLine($"У Вас имеется {balanceCurrencyX} валюты Х, {balanceCurrencyY} валюты Y и {balanceCurrencyZ} валюты Z"); | |
Console.WriteLine("Если хотите закончить конвертации введите \"exit\""); | |
exitCicle = Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment