Question

In: Computer Science

In C#, I have 6 teaching positions. I have to keep my salary expenses below $250,000...

In C#,

I have 6 teaching positions. I have to keep my salary expenses below $250,000 and each position carries insurance and tax costs equal to 25% of their salary.

Create an application that allows me to enter the Years of Experience for 6 teacher positions. Based on those years of experience, look up the minimum salary, total the salaries for all 6 positions. Calculate the 25% tax and insurance expense based on the salaries, and display the total of the tax and insurance expenses to the user. Finally display the total salary, tax, and insurance expenses to the user.

If the total is more than $250,000 then allow the user to start over.

Minimum Salary

Years of Experience

31600

0

31975

1

32350

2

32725

3

33100

4

33500

5

33900

6

This project should include a CalculateTotalSalaries method which returns the total. The salaries should be passed to this method as a parameter.

This project should also include a CalculateTaxAndInsurance method which returns the total tax and insurance expenses based on an array of salaries. The array of salaries should be passed to this method as a parameter.

Solutions

Expert Solution

Required Project Code Files are given below.

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SalaryExpense
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

// method to execute when button calculate is clicked
private void btn_calculate_Click(object sender, EventArgs e)
{
Int32 p1, p2, p3, p4, p5, p6;
if (validateInput())
{
// parsing the experience values
Int32.TryParse(tb_position1.Text, out p1);
Int32.TryParse(tb_position2.Text, out p2);
Int32.TryParse(tb_position3.Text, out p3);
Int32.TryParse(tb_position4.Text, out p4);
Int32.TryParse(tb_position5.Text, out p5);
Int32.TryParse(tb_position6.Text, out p6);

// getting the minimum salaries
Int32 sal1 = getMinimumSalary(p1);
Int32 sal2 = getMinimumSalary(p2);
Int32 sal3 = getMinimumSalary(p3);
Int32 sal4 = getMinimumSalary(p4);
Int32 sal5 = getMinimumSalary(p5);
Int32 sal6 = getMinimumSalary(p6);

// calculating the total minimum salaries
Int64 totalSalary = CalculateTotalSalaries(sal1, sal2, sal3, sal4, sal5, sal6);
// putting the minimum salaries into array
Int64[] salary = { sal1, sal2, sal3, sal4, sal5, sal6 };
// calculating the tax
double tax = CalculateTaxAndInsurance(salary);
// setting the total salary and tax to their respective text fields
tb_total_salary.Text = totalSalary.ToString();
tb_tax.Text = tax.ToString();

}
}

// method for tax calculate
private double CalculateTaxAndInsurance(Int64 []Salary)
{
Int64 totalSalary = 0;
for (int i = 0; i < Salary.Length; i++)
totalSalary += Salary[i];
return (25 * (double)totalSalary / 100);
}

// method to return minimum salary based on experience
private Int32 getMinimumSalary(Int32 exp)
{
if (exp == 0)
return 31600;
else if (exp == 1)
return 31975;
else if (exp == 2)
return 32350;
else if (exp == 3)
return 32725;
else if (exp == 4)
return 33100;
else if (exp == 5)
return 33500;
else if (exp >= 6)
return 33900;
else return 0;
}

// method to calculate and return the total salary
private Int64 CalculateTotalSalaries(Int32 sal1, Int32 sal2, Int32 sal3, Int32 sal4, Int32 sal5, Int32 sal6)
{
return (sal1 + sal2 + sal3 + sal4 + sal5 + sal6);
}

// method to validate input, to check whether all the experience positions are entered or not
private bool validateInput()
{
if (tb_position1.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #1", "Message");
return false;

}

else if (tb_position2.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #2", "Message");
return false;

}
else if (tb_position3.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #3", "Message");
return false;
}

else if (tb_position4.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #4", "Message");
return false;

}

else if (tb_position5.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #5", "Message");
return false;

}

else if (tb_position6.Text.Equals(""))
{
MessageBox.Show("Please enter the years of experience for Position #6", "Message");
return false;
}
else
return true;
}

// button clear click method
private void btn_clear_Click(object sender, EventArgs e)
{
tb_position1.Text = "";
tb_position2.Text = "";
tb_position3.Text = "";
tb_position4.Text = "";
tb_position5.Text = "";
tb_position6.Text = "";

tb_total_salary.Text = "";
tb_tax.Text = "";
}

private void Form1_Load(object sender, EventArgs e)
{
tb_tax.ReadOnly = true;
tb_total_salary.ReadOnly = true;
MaximizeBox = false;
}


}
}

Form1.Designer.cs

namespace SalaryExpense
{
partial class Form1
{
/// <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.grpbox_positions = new System.Windows.Forms.GroupBox();
this.tb_position6 = new System.Windows.Forms.TextBox();
this.tb_position5 = new System.Windows.Forms.TextBox();
this.tb_position4 = new System.Windows.Forms.TextBox();
this.tb_position3 = new System.Windows.Forms.TextBox();
this.tb_position2 = new System.Windows.Forms.TextBox();
this.tb_position1 = new System.Windows.Forms.TextBox();
this.lbl_position6 = new System.Windows.Forms.Label();
this.lbl_position5 = new System.Windows.Forms.Label();
this.lbl_position4 = new System.Windows.Forms.Label();
this.lbl_position3 = new System.Windows.Forms.Label();
this.lbl_position2 = new System.Windows.Forms.Label();
this.lbl_psition1 = new System.Windows.Forms.Label();
this.grpbox_result = new System.Windows.Forms.GroupBox();
this.lbl_tax = new System.Windows.Forms.Label();
this.lbl_totalSalary = new System.Windows.Forms.Label();
this.tb_total_salary = new System.Windows.Forms.TextBox();
this.tb_tax = new System.Windows.Forms.TextBox();
this.btn_clear = new System.Windows.Forms.Button();
this.btn_calculate = new System.Windows.Forms.Button();
this.grpbox_positions.SuspendLayout();
this.grpbox_result.SuspendLayout();
this.SuspendLayout();
//
// grpbox_positions
//
this.grpbox_positions.Controls.Add(this.tb_position6);
this.grpbox_positions.Controls.Add(this.tb_position5);
this.grpbox_positions.Controls.Add(this.tb_position4);
this.grpbox_positions.Controls.Add(this.tb_position3);
this.grpbox_positions.Controls.Add(this.tb_position2);
this.grpbox_positions.Controls.Add(this.tb_position1);
this.grpbox_positions.Controls.Add(this.lbl_position6);
this.grpbox_positions.Controls.Add(this.lbl_position5);
this.grpbox_positions.Controls.Add(this.lbl_position4);
this.grpbox_positions.Controls.Add(this.lbl_position3);
this.grpbox_positions.Controls.Add(this.lbl_position2);
this.grpbox_positions.Controls.Add(this.lbl_psition1);
this.grpbox_positions.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grpbox_positions.Location = new System.Drawing.Point(26, 31);
this.grpbox_positions.Name = "grpbox_positions";
this.grpbox_positions.Size = new System.Drawing.Size(274, 263);
this.grpbox_positions.TabIndex = 0;
this.grpbox_positions.TabStop = false;
this.grpbox_positions.Text = "Enter the years of experience for each teaching positions";
//
// tb_position6
//
this.tb_position6.Location = new System.Drawing.Point(103, 227);
this.tb_position6.Name = "tb_position6";
this.tb_position6.Size = new System.Drawing.Size(100, 21);
this.tb_position6.TabIndex = 6;
//
// tb_position5
//
this.tb_position5.Location = new System.Drawing.Point(103, 191);
this.tb_position5.Name = "tb_position5";
this.tb_position5.Size = new System.Drawing.Size(100, 21);
this.tb_position5.TabIndex = 5;
//
// tb_position4
//
this.tb_position4.Location = new System.Drawing.Point(103, 151);
this.tb_position4.Name = "tb_position4";
this.tb_position4.Size = new System.Drawing.Size(100, 21);
this.tb_position4.TabIndex = 4;
//
// tb_position3
//
this.tb_position3.Location = new System.Drawing.Point(103, 115);
this.tb_position3.Name = "tb_position3";
this.tb_position3.Size = new System.Drawing.Size(100, 21);
this.tb_position3.TabIndex = 3;
//
// tb_position2
//
this.tb_position2.Location = new System.Drawing.Point(103, 79);
this.tb_position2.Name = "tb_position2";
this.tb_position2.Size = new System.Drawing.Size(100, 21);
this.tb_position2.TabIndex = 2;
//
// tb_position1
//
this.tb_position1.Location = new System.Drawing.Point(103, 41);
this.tb_position1.Name = "tb_position1";
this.tb_position1.Size = new System.Drawing.Size(100, 21);
this.tb_position1.TabIndex = 1;
//
// lbl_position6
//
this.lbl_position6.AutoSize = true;
this.lbl_position6.Location = new System.Drawing.Point(19, 230);
this.lbl_position6.Name = "lbl_position6";
this.lbl_position6.Size = new System.Drawing.Size(64, 15);
this.lbl_position6.TabIndex = 5;
this.lbl_position6.Text = "Position 6:";
//
// lbl_position5
//
this.lbl_position5.AutoSize = true;
this.lbl_position5.Location = new System.Drawing.Point(19, 194);
this.lbl_position5.Name = "lbl_position5";
this.lbl_position5.Size = new System.Drawing.Size(64, 15);
this.lbl_position5.TabIndex = 4;
this.lbl_position5.Text = "Position 5:";
//
// lbl_position4
//
this.lbl_position4.AutoSize = true;
this.lbl_position4.Location = new System.Drawing.Point(19, 157);
this.lbl_position4.Name = "lbl_position4";
this.lbl_position4.Size = new System.Drawing.Size(64, 15);
this.lbl_position4.TabIndex = 3;
this.lbl_position4.Text = "Position 4:";
//
// lbl_position3
//
this.lbl_position3.AutoSize = true;
this.lbl_position3.Location = new System.Drawing.Point(19, 120);
this.lbl_position3.Name = "lbl_position3";
this.lbl_position3.Size = new System.Drawing.Size(64, 15);
this.lbl_position3.TabIndex = 2;
this.lbl_position3.Text = "Position 3:";
//
// lbl_position2
//
this.lbl_position2.AutoSize = true;
this.lbl_position2.Location = new System.Drawing.Point(19, 82);
this.lbl_position2.Name = "lbl_position2";
this.lbl_position2.Size = new System.Drawing.Size(64, 15);
this.lbl_position2.TabIndex = 1;
this.lbl_position2.Text = "Position 2:";
//
// lbl_psition1
//
this.lbl_psition1.AutoSize = true;
this.lbl_psition1.Location = new System.Drawing.Point(19, 44);
this.lbl_psition1.Name = "lbl_psition1";
this.lbl_psition1.Size = new System.Drawing.Size(64, 15);
this.lbl_psition1.TabIndex = 0;
this.lbl_psition1.Text = "Position 1:";
//
// grpbox_result
//
this.grpbox_result.Controls.Add(this.tb_tax);
this.grpbox_result.Controls.Add(this.tb_total_salary);
this.grpbox_result.Controls.Add(this.lbl_totalSalary);
this.grpbox_result.Controls.Add(this.lbl_tax);
this.grpbox_result.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grpbox_result.Location = new System.Drawing.Point(26, 366);
this.grpbox_result.Name = "grpbox_result";
this.grpbox_result.Size = new System.Drawing.Size(274, 100);
this.grpbox_result.TabIndex = 1;
this.grpbox_result.TabStop = false;
this.grpbox_result.Text = "Result";
//
// lbl_tax
//
this.lbl_tax.AutoSize = true;
this.lbl_tax.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_tax.Location = new System.Drawing.Point(31, 64);
this.lbl_tax.Name = "lbl_tax";
this.lbl_tax.Size = new System.Drawing.Size(35, 18);
this.lbl_tax.TabIndex = 0;
this.lbl_tax.Text = "Tax";
//
// lbl_totalSalary
//
this.lbl_totalSalary.AutoSize = true;
this.lbl_totalSalary.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_totalSalary.Location = new System.Drawing.Point(31, 29);
this.lbl_totalSalary.Name = "lbl_totalSalary";
this.lbl_totalSalary.Size = new System.Drawing.Size(98, 18);
this.lbl_totalSalary.TabIndex = 1;
this.lbl_totalSalary.Text = "Total Salary";
//
// tb_total_salary
//
this.tb_total_salary.Location = new System.Drawing.Point(145, 28);
this.tb_total_salary.Name = "tb_total_salary";
this.tb_total_salary.Size = new System.Drawing.Size(100, 22);
this.tb_total_salary.TabIndex = 99;
//
// tb_tax
//
this.tb_tax.Location = new System.Drawing.Point(145, 64);
this.tb_tax.Name = "tb_tax";
this.tb_tax.Size = new System.Drawing.Size(100, 22);
this.tb_tax.TabIndex = 100;
//
// btn_clear
//
this.btn_clear.Location = new System.Drawing.Point(218, 320);
this.btn_clear.Name = "btn_clear";
this.btn_clear.Size = new System.Drawing.Size(75, 23);
this.btn_clear.TabIndex = 8;
this.btn_clear.Text = "Clea&r";
this.btn_clear.UseVisualStyleBackColor = true;
this.btn_clear.Click += new System.EventHandler(this.btn_clear_Click);
//
// btn_calculate
//
this.btn_calculate.Location = new System.Drawing.Point(119, 320);
this.btn_calculate.Name = "btn_calculate";
this.btn_calculate.Size = new System.Drawing.Size(75, 23);
this.btn_calculate.TabIndex = 7;
this.btn_calculate.Text = "&Calculate";
this.btn_calculate.UseVisualStyleBackColor = true;
this.btn_calculate.Click += new System.EventHandler(this.btn_calculate_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(362, 478);
this.Controls.Add(this.btn_calculate);
this.Controls.Add(this.btn_clear);
this.Controls.Add(this.grpbox_result);
this.Controls.Add(this.grpbox_positions);
this.Name = "Form1";
this.Text = "Salary Expense Calculator";
this.Load += new System.EventHandler(this.Form1_Load);
this.grpbox_positions.ResumeLayout(false);
this.grpbox_positions.PerformLayout();
this.grpbox_result.ResumeLayout(false);
this.grpbox_result.PerformLayout();
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.GroupBox grpbox_positions;
private System.Windows.Forms.TextBox tb_position6;
private System.Windows.Forms.TextBox tb_position5;
private System.Windows.Forms.TextBox tb_position4;
private System.Windows.Forms.TextBox tb_position3;
private System.Windows.Forms.TextBox tb_position2;
private System.Windows.Forms.TextBox tb_position1;
private System.Windows.Forms.Label lbl_position6;
private System.Windows.Forms.Label lbl_position5;
private System.Windows.Forms.Label lbl_position4;
private System.Windows.Forms.Label lbl_position3;
private System.Windows.Forms.Label lbl_position2;
private System.Windows.Forms.Label lbl_psition1;
private System.Windows.Forms.GroupBox grpbox_result;
private System.Windows.Forms.Label lbl_totalSalary;
private System.Windows.Forms.Label lbl_tax;
private System.Windows.Forms.TextBox tb_tax;
private System.Windows.Forms.TextBox tb_total_salary;
private System.Windows.Forms.Button btn_clear;
private System.Windows.Forms.Button btn_calculate;
}
}

Component Names

Project/Solution Name

OUTPUT


Related Solutions

In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
Below is my C++ program of a student record system. I have done the program through...
Below is my C++ program of a student record system. I have done the program through structures. Please do the same program using classes this time and dont use structures. Also, please make the menu function clean and beautiful if you can. So the output will look good at the end. Thanks. #include<iostream> #include<string> using namespace std; struct StudentRecord {    string name;    int roll_no;    string department;    StudentRecord *next; }; StudentRecord *head = NULL; StudentRecord *get_data() {...
HI. I have been trying to run my code but I keep getting the following error....
HI. I have been trying to run my code but I keep getting the following error. I can't figure out what I'm doing wrong. I also tried to use else if to run the area of the other shapes but it gave me an error and I created the private method. Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt(Scanner.java:2258) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at project2.areacalculation.main(areacalculation.java:26) My code is below package project2; import java.util.Scanner; public class areacalculation { private static...
I have a quick question about this C ++ problem in my intro class. I have...
I have a quick question about this C ++ problem in my intro class. I have been able to get the first answer consistently when I test it, but my second seems to either be high or low no matter how I change it. Can you show me how you would do this problem with the setprecision(2) Paula and Danny want to plant evergreen trees along the back side of their yard. They do not want to have an excessive...
I have to calculate ratios of the 16 stated below. I have Apple as my company...
I have to calculate ratios of the 16 stated below. I have Apple as my company and I have to use financial data of 2017. I also have to show how the ratios are calculated with steps in text. Then give an explanation on each ratio. Below is the Problem. One would have to access Apple's Annual report for 2017 as I cannot post a link. All of this is done in a Excel Sheet with explanations of each ratio....
The data in the table below show years of teaching experience and annual salary in dollars...
The data in the table below show years of teaching experience and annual salary in dollars for 12 randomly selected mathematics instructors in Illinois colleges/ universities for the 2013-2014 school year. Is there a linear correlation between a mathematics instructor's years of experience and their annual salary? a. Draw the scatterplot for the variables. b. Describe the relationship, if any, shown by the scatterplot. c. Calculate r, the correlation coefficient. How does the correlation coefficient compare to the relationship you...
My program is working until it gets to val2 / 1000000. I keep getting my answer...
My program is working until it gets to val2 / 1000000. I keep getting my answer to be 0. Can someone help please? int main() {    int n, num, num1, num2, time, val1, val2, Ts;                printf("**** Welcome to the Time Study Program ****\n");    printf("\n");    printf("Enter the number of elements for the give operation being perform\n");    printf("Number of elements: ");    scanf_s("%d", &n);    printf("\n");    printf("Enter the Performance Rating (PR) factor...
This is a question for my biochemistry class. I have copied and pasted it below. This...
This is a question for my biochemistry class. I have copied and pasted it below. This is all that was given to me. Diagram the flow of genetic material in a cell.
Syntax error in C. I am not familiar with C at all and I keep getting...
Syntax error in C. I am not familiar with C at all and I keep getting this one error "c error expected identifier or '(' before } token" Please show me where I made the error. The error is said to be on the very last line, so the very last bracket #include #include #include #include   int main(int argc, char*_argv[]) {     int input;     if (argc < 2)     {         input = promptUserInput();     }     else     {         input = (int)strtol(_argv[1],NULL, 10);     }     printResult(input);...
This is my C language code. I have some problems with the linked list. I can't...
This is my C language code. I have some problems with the linked list. I can't store the current. After current = temp, I don't know how to move to the next node. current = current-> next keeps making current into NULL. #include #include #include #include struct node{int data; struct node *next;}; int main() {     struct node *head, *current, *temp, *trash;     srand(time(0));     int randNumber = rand()%51;     if(randNumber != 49)     {         temp = (struct node*)malloc(sizeof(struct node));         current = (struct node*)malloc(sizeof(struct node));...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT