Beispiel #1
0
        private void CalculateSalaryButton_Click(object sender, EventArgs e)
        {
            const double PROJECTED_RAISE = .04; //constant for projected 4% raise
            double       salary,                //variable for salary input by user
                         newSalary;             //variable for next year's projected salary

            //convert the user's input salary to a double
            salary = Convert.ToDouble(salaryTextBox.Text);

            //calculate the projected salary for next year
            newSalary = salary + (salary * PROJECTED_RAISE);

            //display the projected salary to the user
            displayLabel.Text = "With a projected raise of " + PROJECTED_RAISE.ToString("P") +
                                "\nyour expected salary for next year is " + newSalary.ToString("C") + ".";
        }
Beispiel #2
0
        public static void ProjectedRaisesInteractive()
        {
            const double PROJECTED_RAISE = .04; //constant for projected 4% raise
            double       salary1,               //variable for the salary of employee1
                         salary2,               //variable for the salary of employee2
                         salary3;               //variable for the salary of employee3

            //get the current salary for each employee
            Write("Enter the current numeric salary for Employee 1: ");
            salary1 = Convert.ToDouble(ReadLine());
            Write("Enter the current numeric salary for Employee 2: ");
            salary2 = Convert.ToDouble(ReadLine());
            Write("Enter the current numeric salary for Employee 3: ");
            salary3 = Convert.ToDouble(ReadLine());

            //calculate the new salary for each employee
            salary1 += salary1 * PROJECTED_RAISE;
            salary2 += salary2 * PROJECTED_RAISE;
            salary3 += salary3 * PROJECTED_RAISE;

            //disaply the projected salary for each employee
            WriteLine("The projected salary of Employee 1 next year with a {0} increase is {1}", PROJECTED_RAISE.ToString("P0"), salary1.ToString("C2"));
            WriteLine("The projected salary of Employee 2 next year with a {0} increase is {1}", PROJECTED_RAISE.ToString("P0"), salary2.ToString("C2"));
            WriteLine("The projected salary of Employee 3 next year with a {0} increase is {1}", PROJECTED_RAISE.ToString("P0"), salary3.ToString("C2"));
        }