Question: Hello! I need help with creating this program in C#. I understand how to convert the inputs of the hours, and hourly rate into decimal

Hello! I need help with creating this program in C#. I understand how to convert the inputs of the hours, and hourly rate into decimal form, but I am stuck from there on... I know I am overthinking this. How do I start the bool/ indicate that the checkbox was checked? So far I have this

private void btnCalculateGrossPay_Click(object sender, EventArgs e) { try {

//DECLARING THE VARIABLES AND CONVERTING THEM TO DECIMALS const decimal baseHours = 40m;

decimal hourlyRate = Convert.ToDecimal(txthourlyRate.Text); decimal hoursWorked = Convert.ToDecimal(txthoursWorked.Text); decimal grossPay;

if (hoursWorked > baseHours) {

grossPay = hoursWorked * hourlyRate + (hoursWorked - 40) * 0.5m * hourlyRate; } else { grossPay = hoursWorked * hourlyRate; }

lblgrossPay.Text = grossPay.ToString("c"); txthourlyRate.Focus(); }

catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }

But I think my calculations for gross pay are wrong as well.

Create a form that has the following controls. The Gross Pay value in the image below (475) is displayed in a label, not a text box. Set the label to have a fixed size and make it the same size as the text boxes. The purpose of the program is to compute and display the grossPay for a one-week pay period for hourly and salaried employees.

The program will have the following methods as follows:

Button Click event method (for the Calculate Gross Pay button)

The method will declare the following 4 variables:

hourlyRate: per hour pay rate (decimal)

hoursWorked: number of hours worked in the week (decimal)

salaried: A bool value to indicate whether the employee salaried (true) or not (false)

grossPay (decimal) to hold the value of the gross pay.

The method will take the values from the two text boxes and the check box (the checked property) and put those values into the first 3 of the above local variables. Do conversions between the text property and decimal as needed.

Test to make sure that the two input values are both >= 0. If either input fails this test, display an informative messagebox and exit the method.

The procedure will call the CalculateGrossPay method (described below) and store the returned value in the grossPay variable.

Display the formatted grossPay value in the output label, formatted as currency.

The CalculateGrossPay method.

Declare this method with the following method header:

private decimal CalculateGrossPay(decimal hourlyRate, decimal hoursWorked, bool salaried)

This method takes the three input values found in the parameters, computes gross pay, and returns that value when done. The logic for computing gross pay is as follows:

If the employee is salaried, gross pay is: 40 * hourlyRate

If the employee is not salaried (theyre hourly), gross pay is:

hoursWorked * hourlyRate (if the employee worked

hoursWorked * hourlyRate + (hoursWorked 40) * 0.5 * hourlyRate (if the employee worked > 40 hours)

The method should return the grossPay amount that is computed.

This method will NOT place the value of grossPay in the label that is the job of the button click event.

The ValueChanged method:

Create a stand-alone void method that replaces the text property of the output label with an empty string ( "" ) any time any input value changes i.e.

When the TextChanged event occurs in either of the text boxes, or

When the CheckedChanged event occurs in the check box.

Use the following method header:

private void ValueChanged(object sender, EventArgs e)

MIS 322 - Program 3 Create a form that has the following controls. The Gross Pay value in the image below (475) is displayed in a label, not a text box. Set the label to have a fixed size and make it the same size as the text boxes. The purpose of the program is to compute and display the grossPay for a one-week pay period for hourly and salaried employees. Chapter 6 Program Steve Hawk Hourly Rate10 Hours Worked 45 Salaried? Gross Pay $475.00 Calclulate Gross Pay The program will have the following methods as follows Button Click event method (for the Calculate Gross Pay button) The method will declare the following 4 variables 1. 2. 3. 4. hourlyRate: per hour pay rate (decimal) hoursWorked: number of hours worked in the week (decimal) salaried: A bool value to indicate whether the employee salaried (true) or not (false) grossPay (decimal) to hold the value of the gross pay The method will take the values from the two text boxes and the check box (the checked property) and put those values into the first 3 of the above local variables. Do conversions between the text property and decimal as needed. Test to make sure that the two input values are both>= 0 messagebox and exit the method. If either input fails this test, display an informative The procedure will call the CalculateGrossPay method (described below) and store the returned value in the grossPay variable Display the formatted grossPay value in the output label, formatted as currency. The CalculateGrossPay method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!