Need help to figure out what I'm doing wrong....???

Discussion in 'C#' started by SNT21409, Feb 8, 2010.

  1. SNT21409

    SNT21409 New Member

    Feb 8, 2010
    Likes Received:
    Trophy Points:
    This is my first time using C# (and I'm not very good with Java either sadly) so I'm a bit confused :/

    I know that the part at the end - " String returnString = calculatePay(hourlyRate, hours);
    Response.Write(pay); " - is wrong, but I'm not sure what's supposed to go there.

    Any help would be greatly appreciated....and if there's anything else that's wrong please feel free to help. If I try to run it, it only gives me the error about the last part, so I don't know if anything really works. Thanks!

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <head runat="server">
        <title>Untitled Page</title>
        <form id="payrollForm" runat="server" action="Default.aspx" method="post">
        <p><strong>Please enter your hourly pay rate.</strong></p>
        <p><input type="text" name="payRate" /></p>
        <br />
        <p><strong>Please enter the number of hours worked.</strong></p>
        <p><input type="text" name="hoursWorked" /></p>
    <script runat="server">
        double hourlyRate;
        double hours;
        double pay;
        double temp_Pay;
        double OT_Payrate;
        double overTimeHours;
        double overTimePay;
        String calculatePay(double hourlyRate, double hours)
            if(hours < 0)
                return "Hours must be greater than or equal to 0!";
            else if(hours <= 40)
                pay = hours * hourlyRate;
                return "Your total pay is: " + pay;
            else if(hours > 40)
                OT_Payrate = hourlyRate * 1.5;
                overTimeHours = hours - 40;
                overTimePay = overTimeHours * OT_Payrate;
                temp_Pay = hours * hourlyRate;
                pay = temp_Pay + overTimePay;
                return "Your total pay is: " + pay;
        String returnString = calculatePay(hourlyRate, hours);

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice