コード例 #1
0
ファイル: Program.cs プロジェクト: tavisca-vrai/Training
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("enter the type of currency and amount of currency ");
                Money input1 = new Money(Console.ReadLine());
                Console.WriteLine("enter the Target currency");
                string targetCurrency = Console.ReadLine();
                targetCurrency = targetCurrency.ToUpper();
                var ans = input1.ConvertCurrency(targetCurrency);
                //Money ans = new Money(string);
                //ans.ConvertCurrency(targetCurrency);
                Console.WriteLine("the converted amount is: {0}", ans);
                /*Console.WriteLine("enter the type of currency and amount of currency ");
                Money input1 = new Money(Console.ReadLine());
                Console.WriteLine("enter the type of currency and amount of currency");
                Money input2 = new Money(Console.ReadLine());
                Money output = input1 + input2;
                Console.WriteLine("the total amount is: " + Output.Currency + " " + Output.Amount);*/

            }
            catch (Exception e)
            {
                Console.WriteLine("the exception is: {0}", e.Message);

            }
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tavisca-akash/Training
        public static void Main(string[] args)
        {
            Money money = new Money();
            string sourceCurrency;
            string targetCurrency;

               Console.WriteLine("Enter Source Currency in \"100 USD\" Format");
               string temporaryString = Console.ReadLine();

               string[] splitInput = temporaryString.Split(' ');
                double temporaryAmount;
                 if((double.TryParse(splitInput[0],out temporaryAmount)==false))
                     throw new Exception(Messages.InvalidParsing);

                 Money money1=new Money( temporaryAmount,splitInput[1]);

            Console.WriteLine("Enter Target Currency");
            if (IsValidCurrency(Console.ReadLine().ToUpper(), out targetCurrency) == false)
                throw new Exception(Messages.InvalidCurrency);
            Money money2 = new Money(targetCurrency);

            double multiplier = money.ConvertCurrency(money1.Currency, money2.Currency);
            Console.WriteLine(multiplier*money1.Amount);
        }