Code given below, suppose to give
hourly pay * number of hours + if hours greator then 37 then calculate rest with given rate (overtime)
and display final result

but its just multiplying pay rate hourly with pay rate for overtime hourly

and i made it in VS 2010 windows application but error is logical as i said.... and its a payroll calculator

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace PayrollSystem
{
    public class partTimeEmployees : Employee
    {
        private decimal wage;       // wage per hour of work
        private double hoursWorked; // hours worked during week
        private decimal overTimeWage; // wage per hour for over time
 
        // constructor
        public partTimeEmployees(string firstNameValue, string LastNameValue,
           decimal wageValue, double hoursWorkedValue, decimal overTimeWageValue)
            : base(firstNameValue, LastNameValue)
        {
            Wage = wageValue;
            HoursWorked = hoursWorkedValue;
            OverTimeWage = overTimeWageValue;
        }
 
        // property Wage
        public decimal Wage
        {
            get
            {
                return wage;
            }
 
            set
            {
                // ensure non-negative wage value
                if (value > 0)
                    wage = value;
            }
        }
        // property HoursWorked
        public double HoursWorked
        {
            get
            {
                return hoursWorked;
            }
 
            set
            {
                // ensure non-negative hoursWorked value
                if (value > 0)
                    hoursWorked = value;
            }
        }
        // property over time Wage
        public decimal OverTimeWage
        {
            get
            {
                return overTimeWage;
            }
 
            set
            {
                // ensure non-negative wage value
                if (value > 0)
                    overTimeWage = value;
            }
        }
 
        // override base-class method to calculate 
        // HourlyWorker earnings
        public override decimal Earnings()
        {
         // compensate for overtime (paid "time-and-a-half")
         if ( HoursWorked <= 37 )
         {
            return Wage * Convert.ToDecimal( HoursWorked );
         }
 
         else
         {
            // calculate base and overtime pay
            decimal basePay = Wage * Convert.ToDecimal(37);
            decimal overtimePay = OverTimeWage * Convert.ToDecimal( HoursWorked - 37);
 
            return basePay + overtimePay;
         }
        }
 
        // return string representation of HourlyWorker
        public override string ToString()
        {
            return "Part Time Employee: " + base.ToString();
        }
    }
 
}

DOne it
thanks for help both of u guyz :)

specially mitja

do you have the error like this

The conflow must be return a value.

Try this

Maintain a decial variable, return it at the end of the method

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.