C# Programming Solution
C# Programming Solution
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
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