Question

In: Computer Science

C# - Visual Studio Community 1.3 In a country XYZ a government organization classifies its employees...

C# - Visual Studio Community

1.3 In a country XYZ a government organization classifies its employees according to categories: A and B. The salary of an employee depends on the number of years of service, and the category of the employee. The gross yearly salary grid is shown below.

Category A

Category B

Years

0-4

$   45,000

$ 52,000

5-9

$   50,000

$ 60,000

10-14

$ 55,000

$ 67,000

15-19

$ 58,000

$ 74,000

>19

$ 60,000

$ 80,000

If an employee earns less than $55,000, the tax rate on income is 30%. Between $55,000 and below $70,000 the rate is 35%. Above $70,000, the rate is 40%. Employees can also choose between 0%, 3%, or 5% option for their yearly pension savings as a percentage of their pay after taxes. Develop an application that will allow indicating employee category (use radio buttons), years of service (text box or list box), and chosen pension saving plan (radio buttons). The application should calculate: 1) the gross salary; 2) taxes deducted; 3) pension deduction; and 4) the net pay (all on a yearly basis).

Solutions

Expert Solution

Code

using System;

using System.Windows.Forms;

public partial class frmMain : Form
{
double[] categoryASalary = { 45000, 50000, 55000, 58000, 60000 };
double[] categoryBSalary = { 52000, 60000, 67000, 74000, 80000 };
public frmMain()
{
InitializeComponent();
}

private void btnCalculate_Click(object sender, EventArgs e)
{
double grossPay=0, taxes, pensionDeduction=0, netPay;
if (rdbCategoryA.Checked)
grossPay = categoryASalary[lstYears.SelectedIndex];
if (rdbCategoryB.Checked)
grossPay = categoryBSalary[lstYears.SelectedIndex];

taxes = calculateTax(grossPay);

if (rdbPension3.Checked)
pensionDeduction = (grossPay - taxes) * 0.03;
if(rdbPension5.Checked)
pensionDeduction = (grossPay - taxes) * 0.05;

netPay = grossPay - taxes - pensionDeduction;
lblGrossPay.Text = grossPay.ToString("C2");
lblNetPay.Text = netPay.ToString("C2");
lblPension.Text = pensionDeduction.ToString("C2");
lblTaxes.Text = taxes.ToString("C2");
}

private double calculateTax(double grossPay)
{
if (grossPay < 55000)
return grossPay * 0.3;
else if(grossPay>=55000 && grossPay<70000)
return grossPay * 0.35;
return grossPay * 0.4;
}
}

Desing

frmMain.Designer.Cs

partial class frmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.rdbCategoryA = new System.Windows.Forms.RadioButton();
this.rdbCategoryB = new System.Windows.Forms.RadioButton();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.rdbPension5 = new System.Windows.Forms.RadioButton();
this.rdbPension0 = new System.Windows.Forms.RadioButton();
this.rdbPension3 = new System.Windows.Forms.RadioButton();
this.lstYears = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.btnCalculate = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.lblGrossPay = new System.Windows.Forms.Label();
this.lblTaxes = new System.Windows.Forms.Label();
this.lblPension = new System.Windows.Forms.Label();
this.lblNetPay = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.rdbCategoryB);
this.groupBox1.Controls.Add(this.rdbCategoryA);
this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox1.Location = new System.Drawing.Point(12, 31);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(252, 63);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Choose Category";
//
// rdbCategoryA
//
this.rdbCategoryA.AutoSize = true;
this.rdbCategoryA.Location = new System.Drawing.Point(16, 29);
this.rdbCategoryA.Name = "rdbCategoryA";
this.rdbCategoryA.Size = new System.Drawing.Size(93, 19);
this.rdbCategoryA.TabIndex = 0;
this.rdbCategoryA.TabStop = true;
this.rdbCategoryA.Text = "Category A";
this.rdbCategoryA.UseVisualStyleBackColor = true;
//
// rdbCategoryB
//
this.rdbCategoryB.AutoSize = true;
this.rdbCategoryB.Location = new System.Drawing.Point(151, 29);
this.rdbCategoryB.Name = "rdbCategoryB";
this.rdbCategoryB.Size = new System.Drawing.Size(94, 19);
this.rdbCategoryB.TabIndex = 1;
this.rdbCategoryB.TabStop = true;
this.rdbCategoryB.Text = "Category B";
this.rdbCategoryB.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.rdbPension3);
this.groupBox2.Controls.Add(this.rdbPension5);
this.groupBox2.Controls.Add(this.rdbPension0);
this.groupBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.groupBox2.Location = new System.Drawing.Point(12, 123);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(252, 63);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Pension savings";
//
// rdbPension5
//
this.rdbPension5.AutoSize = true;
this.rdbPension5.Location = new System.Drawing.Point(178, 29);
this.rdbPension5.Name = "rdbPension5";
this.rdbPension5.Size = new System.Drawing.Size(45, 19);
this.rdbPension5.TabIndex = 1;
this.rdbPension5.TabStop = true;
this.rdbPension5.Text = "5%";
this.rdbPension5.UseVisualStyleBackColor = true;
//
// rdbPension0
//
this.rdbPension0.AutoSize = true;
this.rdbPension0.Location = new System.Drawing.Point(16, 29);
this.rdbPension0.Name = "rdbPension0";
this.rdbPension0.Size = new System.Drawing.Size(45, 19);
this.rdbPension0.TabIndex = 0;
this.rdbPension0.TabStop = true;
this.rdbPension0.Text = "0%";
this.rdbPension0.UseVisualStyleBackColor = true;
//
// rdbPension3
//
this.rdbPension3.AutoSize = true;
this.rdbPension3.Location = new System.Drawing.Point(97, 29);
this.rdbPension3.Name = "rdbPension3";
this.rdbPension3.Size = new System.Drawing.Size(45, 19);
this.rdbPension3.TabIndex = 2;
this.rdbPension3.TabStop = true;
this.rdbPension3.Text = "3%";
this.rdbPension3.UseVisualStyleBackColor = true;
//
// lstYears
//
this.lstYears.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lstYears.FormattingEnabled = true;
this.lstYears.ItemHeight = 15;
this.lstYears.Items.AddRange(new object[] {
"0 - 4",
"5 - 9",
"10 - 14",
"15 - 19",
">19"});
this.lstYears.Location = new System.Drawing.Point(73, 226);
this.lstYears.Name = "lstYears";
this.lstYears.Size = new System.Drawing.Size(120, 94);
this.lstYears.TabIndex = 3;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(70, 210);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 15);
this.label1.TabIndex = 4;
this.label1.Text = "Years of service,";
//
// btnCalculate
//
this.btnCalculate.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnCalculate.Location = new System.Drawing.Point(73, 362);
this.btnCalculate.Name = "btnCalculate";
this.btnCalculate.Size = new System.Drawing.Size(120, 32);
this.btnCalculate.TabIndex = 5;
this.btnCalculate.Text = "Calculate";
this.btnCalculate.UseVisualStyleBackColor = true;
this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(25, 425);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(96, 15);
this.label2.TabIndex = 6;
this.label2.Text = "Gross Salary: ";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(25, 452);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 15);
this.label3.TabIndex = 7;
this.label3.Text = "Taxes";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(25, 481);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(126, 15);
this.label4.TabIndex = 8;
this.label4.Text = "Pension deduction";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(25, 509);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(63, 15);
this.label5.TabIndex = 9;
this.label5.Text = "Net pay: ";
//
// lblGrossPay
//
this.lblGrossPay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblGrossPay.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblGrossPay.Location = new System.Drawing.Point(159, 421);
this.lblGrossPay.Name = "lblGrossPay";
this.lblGrossPay.Size = new System.Drawing.Size(105, 24);
this.lblGrossPay.TabIndex = 10;
//
// lblTaxes
//
this.lblTaxes.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblTaxes.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTaxes.Location = new System.Drawing.Point(159, 452);
this.lblTaxes.Name = "lblTaxes";
this.lblTaxes.Size = new System.Drawing.Size(105, 24);
this.lblTaxes.TabIndex = 11;
//
// lblPension
//
this.lblPension.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblPension.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPension.Location = new System.Drawing.Point(159, 481);
this.lblPension.Name = "lblPension";
this.lblPension.Size = new System.Drawing.Size(105, 24);
this.lblPension.TabIndex = 12;
//
// lblNetPay
//
this.lblNetPay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblNetPay.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblNetPay.Location = new System.Drawing.Point(159, 509);
this.lblNetPay.Name = "lblNetPay";
this.lblNetPay.Size = new System.Drawing.Size(105, 24);
this.lblNetPay.TabIndex = 13;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(286, 540);
this.Controls.Add(this.lblNetPay);
this.Controls.Add(this.lblPension);
this.Controls.Add(this.lblTaxes);
this.Controls.Add(this.lblGrossPay);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnCalculate);
this.Controls.Add(this.label1);
this.Controls.Add(this.lstYears);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "frmMain";
this.Text = "The gross yearly salary";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton rdbCategoryB;
private System.Windows.Forms.RadioButton rdbCategoryA;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton rdbPension3;
private System.Windows.Forms.RadioButton rdbPension5;
private System.Windows.Forms.RadioButton rdbPension0;
private System.Windows.Forms.ListBox lstYears;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnCalculate;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label lblGrossPay;
private System.Windows.Forms.Label lblTaxes;
private System.Windows.Forms.Label lblPension;
private System.Windows.Forms.Label lblNetPay;
}

Output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
Write a C program of car sale: The Visual Studio project itself must make its output...
Write a C program of car sale: The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 10%: Looping Menu with 2 main actions: Sell Car, View Sales Note: A Car is defined only by its price 10% Must contain at least one array containing sales figures (each entry represents the price of one vehicle) for a maximum of 10 Cars 5%:...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Create a C++ project in visual studio. You can use the C++ project that I uploaded...
Create a C++ project in visual studio. You can use the C++ project that I uploaded to complete this project. 1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following three arrays: int array1 [] = { 3, 4, 2, 1, 7}; float array2 [] = {0.3, 0.1, 5.5, 4.3, 7.8}; char array3 [] = {‘c’, ‘d’, ‘a’, ‘b’, ‘f’};                                     Develop a driver function to print out the sorted results and put the screenshot into the word document. Note that you have to use qsort( ) provided by Visual Studio. What is the...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
 VISUAL STUDIO (File Creation and Submissions)  FLOWCHART  Writing program in C++ ( cout,...
 VISUAL STUDIO (File Creation and Submissions)  FLOWCHART  Writing program in C++ ( cout, \n, \t, solving expressions )  Correcting errors Q1: Draw flow Chart of the following problems: a) Display “Hello World” on screen. b) Display Your Name, date of birth and mobile number on screen. c) Compute and display the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches. d) Compute and display the perimeter and area...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
The Canadian Government is considering building apartment units for its employees working in a foreign country....
The Canadian Government is considering building apartment units for its employees working in a foreign country. These employees are currently living in rental houses owned by local landlords. Currently, the government reimburses the employees their housing and transportation expenses. Two mutually exclusive locations for building the apartments, are shown in the following data:           LOCATION A LOCATION B Original Investment by the Government            $8,000,000           $10,000,000 Estimated Annual Maintenance Expenses $360,000                $350,000 Government Savings in annual Reimbursements    $1,960,000             $2,100,000 Assume the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT