Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:43:49+00:00 2026-05-31T12:43:49+00:00

Working on a class assignment and when I run this code function paycheck1($hours,$payrate,$othours,$otrate){ if

  • 0

Working on a class assignment and when I run this code

function paycheck1($hours,$payrate,$othours,$otrate){
        if ($hours > $othours){
            $total = "<tr><td>".($hours*$payrate)+($hours - $othours)*$otrate."</td></tr>";
        return $total;  
        }
        else{
            $total = "<tr><td>".$hours * $payrate."</td></tr>";
            return $total;
        }
}

$pay = 10;
$hours = 50;
$overtime_starts = 40;
$overtime_rate = 15; 
echo "<table>";
for ($i=0;$i<$hours;$i++){
echo paycheck1($i, $pay, $overtime_starts, $overtime_rate);
}
echo "</table>";

I get output like this

153045607590105120135
0
10
20
30
40.....

Why am I getting 153045607590105120135 When I run the code. If I remove the ($hours*$payrate)+ from the function->if it works just fine. Why am I getting what I use is an overflow error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:43:50+00:00Added an answer on May 31, 2026 at 12:43 pm

    It’s easier to find the problem in the source if you put newlines at the end of your html, like:

    $total = "<tr><td>".($hours * $payrate)."</td></tr>\n";
    

    Also, you have to pay attention to the order of operations, even with the . operator.

    This line:

    $total = "<tr><td>".($hours*$payrate)+($hours - $othours)*$otrate."</td></tr>\n";
    

    Needs parenthesis:

    $total = "<tr><td>".(($hours*$payrate)+($hours - $othours)*$otrate)."</td></tr>\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an assignment for my programming class but I've run into some
I'm working on a assignment for class so this is only part of the
ok so this is the assignment that I'm working on: Implement a class Student
This is an assignment i am working on for class. To make a long
I'm working on a class assignment that started small, so I had it all
We are working on a lab assignment for my CS&E class and I think
Does anyone have a working class or function to create the hashed email that
I am working on a C++ assignment for class that wants me to overload
I'm working on an assignment has a class hierarchy like blow: abstract EventClass someEventClass1
I'm new to C++ and was working on an assignment for a class. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.