TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jenni Witzel
NA
27
0
i need help with dis code will take any ideas
Dec 10 2008 9:48 PM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JKingLab15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void clear_Click(object sender, EventArgs e)
{
empName.Clear();
hours.Clear();
code.Clear();
rate.Clear();
desc.Clear();
noBonus.Clear();
bonus.Clear();
withBonus.Clear();
state.Clear();
fed.Clear();
fica.Clear();
net.Clear();
}
private void exit_Click(object sender, EventArgs e)
{
this.Close();
}
private void compute_Click(object sender, EventArgs e)
{
string employeeName = Convert.ToString(empName.Text);
double hoursworked = Convert.ToDouble(hours.Text);
int jobCode = Convert.ToInt32(code.Text);
//double hoursworked = Convert.ToDouble(hours.Text);
empName.Text = String.Concat(empName.ToString());
while (employeeName != "Quit" && employeeName != "quit")
{
do
{
hours.Text = String.Concat(hours.ToString());
}
while (hoursworked <= 0 || hoursworked > 65);
do
{
code.Text = String.Concat(code.ToString());
} while (jobCode < 1 || jobCode > 8);
if (jobCode == 3 || jobCode == 7)
{
BonusEmployee newBonusEmployee = new BonusEmployee(employeeName, hoursWorked, jobCode);
newBonusEmployee.OutputName();
newBonusEmployee.OutputJobInfo();
newBonusEmployee.CalculateGrossPay();
newBonusEmployee.CalculateStateTax();
newBonusEmployee.CalculateFederalTax();
newBonusEmployee.CalculateFICATax();
newBonusEmployee.CalculateNetPay();
}
else
{
Employee newEmployee = new Employee(employeeName, hoursWorked, jobCode);
newEmployee.OutputName();
newEmployee.OutputJobInfo();
newEmployee.CalculateGrossPay();
newEmployee.CalculateStateTax();
newEmployee.CalculateFederalTax();
newEmployee.CalculateFICATax();
newEmployee.CalculateNetPay();
}
//SC.Write("\nPlease input Employee Name: ");
empName.Text = String.Concat(empName.ToString());
} // end of loop
} // end of Main Method
// end of Main class
class Employee
{
protected string employeeName = Convert.ToString(empName.Text);
protected string employeeJob = Convert.ToString(desc.Text);
double rateOfPay = Convert.ToDouble(rate.Text);
double grossPay = Convert.ToDouble(noBonus.Text);
double stateTax = Convert.ToDouble(state.Text);
double federalTax = Convert.ToDouble(fed.Text);
double ficaTax = Convert.ToDouble(fica.Text);
double netPay = Convert.ToDouble(net.Text);
private double[] hourlyRates = { 0.00, 7.25, 9.25, 9.75, 10.50, 11.50, 12.25, 13.75, 14.60 };
private string[] jobDescriptions = {"no such job", "Assistant Machine Wipe",
"Machine Wipe", "Master Machine Wipe", "Assistant Maintenance Engineer",
"Maintenance Engineer", "Assistant Shift Foreman", "Shift Foreman", "Night Foreman"};
protected double hoursWorked, rateOfPay, grossPay, stateTax, federalTax,
ficaTax, netPay;
public Employee(string eName, double hours, int jobCode)
{
employeeName = eName;
hoursWorked = hours;
rateOfPay = hourlyRates[jobCode];
employeeJob = jobDescriptions[jobCode];
}
public void OutputName()
{
empName.Text = employeeName;
}
public void OutputJobInfo()
{
hours.Text = String.Concat(hourlyRates[jobCode].ToString());
code.Text = String.Concat(jobDescriptions[jobCode].ToString());
}
public void CalculateGrossPay()
{
if (hoursWorked > 40)
grossPay = 40 * rateOfPay + (hoursWorked - 40) * (rateOfPay * 1.5);
else
grossPay = hoursWorked * rateOfPay;
noBonus.Text = String.Concat(noBonus.ToString());
}
public void CalculateStateTax()
{
stateTax = grossPay * .04;
state.Text = String.Concat(state.ToString());
}
public void CalculateFederalTax()
{
federalTax = grossPay * .23;
fed.Text = String.Concat(fed.ToString());
}
public void CalculateFICATax()
{
ficaTax = grossPay * .14;
fica.Text = String.Concat(fica.ToString());
}
public void CalculateNetPay()
{
netPay = grossPay - (stateTax + federalTax + ficaTax);
net.Text = String.Concat(net.ToString());
}
}
class BonusEmployee : Employee
{
private double grossBeforeBonus, bonus;
public BonusEmployee(string eName, double hours, int jobCode) :
base(eName, hours, jobCode)
{
// nothing else to do here
}
new public void CalculateGrossPay()
{
if (hoursWorked > 40)
grossBeforeBonus = 40 * rateOfPay + (hoursWorked - 40) * (rateOfPay * 1.5);
else
grossBeforeBonus = hoursWorked * rateOfPay;
bonus = grossBeforeBonus * .15;
grossPay = grossBeforeBonus + bonus;
noBonus.Text = String.Concat(noBonus.ToString());
bonus.Text = String.Concat(bonus.ToString());
withBonus.Text = String.Concat(noBonus.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label10_Click(object sender, EventArgs e)
{
}
private void label11_Click(object sender, EventArgs e)
{
} // end of BonusEmployee class
}
}
Reply
Answers (
2
)
Deployment with C# 2005 Express
Excel Export in XML format instead of .xla