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 7631045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:15:11+00:00 2026-05-31T06:15:11+00:00

Okay so part two on this. I restructured the code on this but now

  • 0

Okay so part two on this. I restructured the code on this but now I can’t figure out a way to return back the empWeeklyPay without initializing it to zero. And if I initialize it to zero then my pay will always be zero? Can anyone think of anything I can do?

public double getWeeklyPay()//Call the getWeeklyHours method of the Emp's timecard to      get the total
//hours worked and then multiply the returned value by the emp's hourly rate and return the value.
{
TimeCard empTimeCard = timeCard;
double empWeeklyPay;
double totalOtHours;
double totalRegHours;
int i = 0;

while(i <= empTimeCard.NUMDAYS && empTimeCard.getHoursByDay(i) > 8)
{
double empHourlyRate = getHourlyRate();
double otHours = 0;
double regHours = 0;
double sumOtHours = 0;
int sumRegHours = 0;

//grabbing the overtime and reghours and storing them
otHours = empTimeCard.getHoursByDay(i) % 8;
regHours = empTimeCard.getHoursByDay(i) - otHours;
sumOtHours += otHours;
sumRegHours += regHours;
double tmpBasePay = (sumRegHours * empHourlyRate) + (sumOtHours * empHourlyRate * 1.5);

if(Integer.toString(getEmployeeId()).charAt(0) == '0' || Integer.toString(getEmployeeId()).charAt(0) == '2'
|| Integer.toString(getEmployeeId()).charAt(0) == '9')
//Java reads in 1010 so need to convert to a string to do a count on the value.
{
  tmpBasePay += (tmpBasePay * .10);        
  i++;
}
else if(Integer.toString(getEmployeeId()).charAt(0) == '3')
{
  tmpBasePay -= (tmpBasePay *.10);
  i++;
}
else if(Integer.toString(getEmployeeId()).charAt(0) == '8')
{ 
  tmpBasePay += (tmpBasePay * .20);
  i++;
}
totalRegHours = regHours;
totalOtHours = sumOtHours;
if(totalRegHours > 34)
{
tmpBasePay -= (tmpBasePay * .06);
//empWeeklyPay = tmpBasePay;
empWeeklyPay = tmpBasePay;
}
else
{
empWeeklyPay = tmpBasePay;
}

}

return empWeeklyPay;// <---need to return back this value.   
  • 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-31T06:15:13+00:00Added an answer on May 31, 2026 at 6:15 am

    Here is the answer to my question. I was able to figure it out. Please see code below in case someone else faces this same problem in the near or distant future:

    public double getWeeklyPay() {
    // Call the getWeeklyHours method of the Emp's timecard to get the total hours worked
    // and then multiply the returned value by the emp's hourly rate and return the value.
    
    double empWeeklyPay;
    double sumOtHours = 0;
    double sumRegHours = 0;
    int i = 0;
    
    
    while(i < getTimeCard().NUMDAYS) {
    // grabbing the overtime and regHours and storing them
    
        double otHours = 0;
        double regHours = 0;
        otHours += getTimeCard().getHoursByDay(i);
        regHours += getTimeCard().getHoursByDay(i) - otHours;
        sumOtHours += otHours;
        sumRegHours += regHours;
        i++;
    }    
    
    empWeeklyPay = (sumRegHours * getHourlyRate()) + (sumOtHours * getHourlyRate() * 1.5);
    
    if(Integer.toString(getEmployeeId()).charAt(0) == '0' || Integer.toString(getEmployeeId()).charAt(0) == '2'
    || Integer.toString(getEmployeeId()).charAt(0) == '9') {
    // Java reads in 1010 so need to convert to a string to do a count on the value.
    
        double tmpBasePay = (sumRegHours * getHourlyRate()) + (sumOtHours * getHourlyRate() * 1.5);  
        tmpBasePay += (tmpBasePay * .10); 
        empWeeklyPay = tmpBasePay;
    }
    
    else if(Integer.toString(getEmployeeId()).charAt(0) == '3') {
      double tmpBasePay = (sumRegHours * getHourlyRate()) + (sumOtHours * getHourlyRate() * 1.5);
        tmpBasePay -= (tmpBasePay * .10);
        empWeeklyPay = tmpBasePay;
    }
    
    else if(Integer.toString(getEmployeeId()).charAt(0) == '8') { 
        double tmpBasePay = (sumRegHours * getHourlyRate()) + (sumOtHours * getHourlyRate() * 1.5);  
        tmpBasePay += (tmpBasePay * .20);
        empWeeklyPay = tmpBasePay;
    }
    
    if(sumRegHours > 34) {
        empWeeklyPay -= (empWeeklyPay * .06 );
        return empWeeklyPay;
    }
    
    else
        return empWeeklyPay;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so im working on this php image upload system but for some reason
Okay, I've seen but haven't programmed in C# before. You can assume I'm competent
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, so this is really werid. I've never encountered anything like this. Part of
Okay, this might be a very silly beginner question, but: I've got an ClassA,
Okay this is part of my search results project, in it, I have description
I have a two part question. The first I think I have an okay
Okay, I have been messing with this autocomplete stuff for 2 weeks now, and
This article showed me how to install fonts from a script, but now I'm
Okay, this will probably get closed or get some negative replies, but I've been

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.