0% found this document useful (0 votes)
497 views

C# Programming Solution

This document discusses the requirements, pseudocode, and implementation for a C# payroll program. It outlines the input and output variables needed which include employee name, hours worked, hourly rate, and weekly pay. Pseudocode is provided for both a simple program and one with a GUI using Windows Forms. The pseudocode demonstrates getting input, calculating pay if hours are over 40 by paying overtime at 1.5 times the normal rate, and displaying the output. References for further C# and payroll programming are also included.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
497 views

C# Programming Solution

This document discusses the requirements, pseudocode, and implementation for a C# payroll program. It outlines the input and output variables needed which include employee name, hours worked, hourly rate, and weekly pay. Pseudocode is provided for both a simple program and one with a GUI using Windows Forms. The pseudocode demonstrates getting input, calculating pay if hours are over 40 by paying overtime at 1.5 times the normal rate, and displaying the output. References for further C# and payroll programming are also included.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Running Head: C# Payroll Program

Name Course Date Instructor

C# Payroll Program C# Payroll Programming Solution Requirements Analysis Input variables string employeeName double hours double rate double weeklyPay Processes public void acceptDetails () private void calculatePay() public void displayResult() Output variables string employeeName double hours double rate double weeklyPay

C# Payroll Program Pseudocode for the Payroll Application Simple Pseudocode

Do While Get employeeName, hours, rate If hours>40 Basepay=40*rate Base= 40 Overhours=hours-40 Overtime=Overhours*payrate*1.5 Else Basepay=hours*rate Base=hours Overtime=0 Overhours=0 Endif Grosspay=Basepay+Overtime Display employeeName, hours,rate, weeklyPay End Do Pseudocode Implementation for GUI based system using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace WageCalculator

C# Payroll Program { public class WageCalculator:System.Windows.Forms.Form{ private System.Windows.Forms.Label weeklyPay; private System.Windows.Forms.TextBox txtPay; private System.Windows.Forms.Label WeeklyEarnings; private System.Windows.Forms.Label WeeklyEarningsResult; private System.Windows.Forms.Button Calculate; private System.ComponentModel.Container components=null; Public WageCalculator() { IntializeComponent(); } protected override void Dispose (bool disposing) { if (disposing) { if (components !=null)

C# Payroll Program { components.Dispose(); } } base.Dispose (disposing); } static void Main() { Application.Run (new WageCalculator() ); } private void Calculate_Click(object sender, System.EventArgs e) { string employeeName double hours const double rate double weeklyPay const int hours_limit=40

C# Payroll Program hours=Double.Parse (textHours.Text); weeklyPay=Decimal.Parse(textPay.Text); if (hours<=hours_limit) weeklyPay=(decimal) hours* rate weeklyEarninglyResult.Text= String.Format({0:C}, weeklyPay); } } } Pseudocode Implementation for Command Line using System.Collections.Generic; using System.Text; using System; namespace wageCalculator { public class Program { public static void Main(string[] args) { System.Console.Write("enter employee name: "); string employeeName=Console.ReadLine() System.Console.Write("number of hours worked: "); string hours = Console.ReadLine(); / double rate; double weeklyPay; double numberofHours; if(numberofHours == 40) rate = 10; else payRate =0;

C# Payroll Program

weeklyPay = rate * hours; System.Console.WriteLine(); System.Console.WriteLine(weeklyPay); System.Console.Write("Execution complete, press any key to exit"); System.Console.ReadLine(); } }

C# Payroll Program References Drayton et al. (2002). C# Language Pocket Reference. O'Reilly Petzold, C.(2002). Programming Microsoft Windows with C#. Microsoft Press. Orgersen, Mads (October 27, 2008). "New features in C# 4.0". Osborn, John (2000-08-01), Deep Inside C#: An Interview with Microsoft Chief Architect Anders Hejlsberg, O'Reilly Media

You might also like