Esempio n. 1
0
        /*
         * Reads double inputs, represented as amounts in SEK, until 0 is provided.
         * The input is added to a sum variable that later is used to convert the
         * sum to a foreign currency.
         */
        private void ReadSwedishCurrencyAmounts()
        {
            decimal floatInput;

            do
            {
                Console.Write("Write an amount in Swedish currency to add to the total: ");
                floatInput       = (decimal)ConsoleInput.ReadDouble();
                sumOfSekAmounts += floatInput;
            }while (Math.Round(floatInput, 7) != 0);
        }
        /* Reads and adds entered float numbers to a sum variable until a 0 was entered. */
        private void ReadFloatNumbers()
        {
            bool zeroEntered = false;

            while (!zeroEntered) // Keep going until 0 is entered
            {
                Console.Write("Write a number to add to the sum: ");
                double floatInput = ConsoleInput.ReadDouble();
                sumOfAllFloatNumbers += floatInput;

                if (Math.Round(floatInput, 7) == 0.0)
                {
                    zeroEntered = true;
                }
            }
        }
Esempio n. 3
0
 /* Reads the foreign currency exhange rate in proportion to SEK currency. */
 private void ReadForeignCurrencyExchangeRate()
 {
     Console.Write("Enter the foreign currency exchange rate, meaning how many " +
                   "SEK are equal to 1 " + foreignCurrency + ": ");
     foreignCurrencyExchangeRate = (decimal)ConsoleInput.ReadDouble();
 }