1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

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

  1. SNT21409

    SNT21409 New Member

    Joined:
    Feb 8, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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!


    Code:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="payrollForm" runat="server" action="Default.aspx" method="post">
        <div>
        <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>
        </div>
        </form>
    <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;
            }
        }
    </script>            
    <%
        String returnString = calculatePay(hourlyRate, hours);
        Response.Write(pay);    
    %>
    </body>
    </html>
     

Share This Page