Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            HourlyCalculation calc = new HourlyCalculation();

            if (!string.IsNullOrEmpty(hourRate.Text))
            {
                // Setting the currency formatting.
                var     payRate = hourRate.Text.Replace("$", "");
                decimal result;

                // If the string parses successfuly.
                if (decimal.TryParse(payRate, out result))
                {
                    // Set the output to the mainAmount variable.
                    double mainAmount = Convert.ToDouble(result);
                    string completeGross;
                    string completeMonth;
                    string completeYear;

                    // Set the text boxes to the calculated amounts.
                    completeGross    = calc.checkCalc(mainAmount).ToString("C", CultureInfo.CurrentCulture);
                    grossAmount.Text = completeGross;

                    completeMonth    = calc.monthlyCalculation(mainAmount).ToString("C", CultureInfo.CurrentCulture);
                    monthAmount.Text = completeMonth;

                    completeYear    = calc.yearlyCalculation(mainAmount).ToString("C", CultureInfo.CurrentCulture);
                    yearAmount.Text = completeYear;
                }
            }
            else
            {
                hourRate.Focus();
            }
        }
Exemplo n.º 2
0
        public void HourlyTests()
        {
            double            rate        = 10.00;
            double            expectedPay = 800.00;
            HourlyCalculation cals        = new HourlyCalculation();

            if (cals.checkCalc(rate) == expectedPay)
            {
                Console.WriteLine("Correct");
            }
            else
            {
                Console.WriteLine("Incorrect");
            }
        }