Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Need help to figure out what I'm doing wrong....??? (http://www.go4expert.com/forums/help-figure-im-doing-wrong-t20905/)

SNT21409 8Feb2010 07:36

Need help to figure out what I'm doing wrong....???
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);

All times are GMT +5.5. The time now is 08:04.