C#, Visual Studio 2017 Employee Number Employee Namber 9 Employee Name 9 Employe
ID: 3739958 • Letter: C
Question
C#, Visual Studio 2017
Employee Number Employee Namber 9 Employee Name 9 Employee Name Houry Employee Salay Employoe O Hourly Employee Salary Employo Hours Rale Annual Salary 35 0 355 6 0 65 170 170 75 ?? B 5 15 000 16 000 17000 8 000 75 18 0 38 5 300 305 21 000 22,000 10.5 Employee Number 5202 Employee Name: Bobby Williams Pay: $384.62 23 000 24.000 25.000 Caloulate Exit Ext OK Instructions: In this exercise, you will develop and code an application that leverages overloaded methods to accept user input and display values to the user using a message box. Complete the user interface based on the Form shown above. Image file available on canvas o The hourly radio button should be checked by default and the annual salary label and list box should be hidden by default when the application loads. Use the checked change events for both radio buttons to hide and show the appropriate labels and lists boxes as illustrated in the above figures. The employee number and employee name textboxes should also clear anytime either of the checked change events occur o o Use the form load event to populate the hour, rate and salary list boxes with values. The hours list box should display values from 0.5 to 40 in increments of 0.5. The rate list box should display values from 7 to 14 in increments of 0.5. Lastly, the salary list box should display values from o On load 40.0 and 10.0 should be the selected items for the hours, rate list boxes respectively Write two overloaded methods named DisplayWeeklyPay that accepts arguments representing the 15,000 to 35,000 in increments of 1000 Be sure to assign meaningful names to the form controls. employee number, employee name, and appropriate pay information based on what the user has entered and selected. The first method version should accept the hour and rate to calculate the weekly pay for an hourly employee. The second method version should accept the salary amount and divide it by 52 to display the weekly pay amount. Both methods should have a void return type (not return a value) and display a message box to the user as shown above -The calculate button should check which radio button is selected and call the appropriate methodExplanation / Answer
Note: It is working fine. Please let me know if you have any doubts. Always be there to help you.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RPM_Manufacturing
{
public partial class RPM_Form : Form
{
public RPM_Form()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
lblAnnualSalary.Visible = listBoxAnnSal.Visible = false;
for (double i = 0.5; i <= 40.0; i+= 0.5)
{
listBoxHours.Items.Add(i);
}
for (double j = 7; j <= 14.0; j+=0.5)
{
listBoxRate.Items.Add(j);
}
for (int k = 15000; k <= 35000; k += 1000)
{
listBoxAnnSal.Items.Add(k);
}
listBoxHours.SelectedIndex = 79;
listBoxRate.SelectedIndex = 6;
listBoxAnnSal.SelectedIndex = 5;
}
private void btnCalculate_Click(object sender, EventArgs e)
{
if (!CalcVal())
return;
if (radbtnHourlyEmp.Checked)
{
DisplayWeeklyPayForHourlyEmployee();
}
else
{
DisplayWeeklyPayForAnnualEmployee();
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void radbtnHourlyEmp_CheckedChanged(object sender, EventArgs e)
{
lblHours.Visible = lblRate.Visible = listBoxHours.Visible = listBoxRate.Visible = true;
lblAnnualSalary.Visible = listBoxAnnSal.Visible = false;
txtEmpName.Text = txtEmpNo.Text = string.Empty;
listBoxHours.SelectedIndex = 79;
listBoxRate.SelectedIndex = 6;
}
private void radbtnSalEmp_CheckedChanged(object sender, EventArgs e)
{
lblAnnualSalary.Visible = listBoxAnnSal.Visible = true;
lblHours.Visible = lblRate.Visible = listBoxHours.Visible = listBoxRate.Visible = false;
listBoxAnnSal.SelectedIndex = 5;
}
public void DisplayWeeklyPayForHourlyEmployee()
{
Double Hours = Convert.ToDouble(listBoxHours.SelectedItem);
Double Rate = Convert.ToDouble(listBoxRate.SelectedItem);
Double WeeklyPay = Convert.ToDouble(Hours * Rate);
MessageBox.Show("Employee Number:" + txtEmpNo.Text + Environment.NewLine + "Employee Name:" + txtEmpName.Text + Environment.NewLine + "Pay: $" + Math.Round(WeeklyPay, 2));
}
public void DisplayWeeklyPayForAnnualEmployee()
{
Double Salary = Convert.ToDouble(listBoxAnnSal.SelectedItem);
Double WeeklyPay = Convert.ToDouble(Salary / 52);
MessageBox.Show("Employee Number:" + txtEmpNo.Text + Environment.NewLine + "Employee Name:" + txtEmpName.Text + Environment.NewLine + "Pay: $" + Math.Round(WeeklyPay, 2));
}
public bool CalcVal()
{
if (txtEmpNo.Text == string.Empty)
{
MessageBox.Show("Enter Employee number");
return false;
}
if (txtEmpName.Text == string.Empty)
{
MessageBox.Show("Enter Employee name");
return false;
}
return true;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.