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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:39:49+00:00 2026-06-09T20:39:49+00:00

I am having a couple problems with my code. First off, with the code

  • 0

I am having a couple problems with my code.

First off, with the code like it is, No matter what information I put in, It always returns 0, Any suggestions on where to fix this and how? I believe it has something to do with my Class Employee. How would I go about fixing this?

Second, How do I access the information in int total()? I need to access it for the last bit of code.

Also if you notice anything else that I can do to optimize my program, I welcome your suggestions. I am learning C++ as I go and will always be a Student.

// Datamax.cpp
// Created by Kennith Adkins

#include <iostream>
#include <string>

using namespace std;

class Employee
{
public:
string eName;
float eHours;
float eWage;
float ePay;
float eOvertimeHours;
float eOvertimePay;
float eTotalPay;
float eTotalBaseHours;
float eTotalSalary;
float eTotalOvertimeHours;

int Overtime ()
{
    if (eHours > 40)
    {
        eOvertimeHours = (eHours - 40);
        eOvertimePay = (eOvertimeHours * (eWage * 1.5));
        ePay = ((eHours - eOvertimeHours) * eWage);
        eTotalPay = ePay + eOvertimePay;
    }
    else
    {
        ePay = (eHours * eWage);
    }
}
int total()
{
    eTotalBaseHours = (employee1.eHours - employee1.eOvertimeHours) +   (employee2.eHours - employee2.eOvertimeHours) + (employee3.eHours -   employee3.eOvertimeHours);
    eTotalSalary = (employee1.eTotalPay + employee2.eTotalPay + employee3.eTotalPay);
    eTotalOvertimeHours = (employee1.eOvertimeHours + employee2.eOvertimeHours        + employee3.eOvertimeHours);
}
} employee1, employee2, employee3;

// Start the main program here
int main()
{
// Gretting
cout << "Welcome to the Employee Pay Center\n";

// Employee1 information
cout << "Enter the employee name: ";
cin >> employee1.eName;
cout << "Enter the hours worked: ";
cin >> employee1.eHours;
cout << "Enter his or her hourly wage: ";
cin >> employee1.eWage;
cout << endl; // Adding a blank line to space the information out

// Employee2 information
cout << "Enter the employee name: ";
cin >> employee2.eName;
cout << "Enter the hours worked: ";
cin >> employee2.eHours;
cout << "Enter his or her hourly wage: ";
cin >> employee2.eWage;
cout << endl; // Adding a blank line to space the information out

// Employee3 information
cout << "Enter the employee name: ";
cin >> employee3.eName;
cout << "Enter the hours worked: ";
cin >> employee3.eHours;
cout << "Enter his or her hourly wage: ";
cin >> employee3.eWage;
cout << endl; // Adding a blank line to space the information out

// Returning the information to the Employeer
cout << "Employe Name ............ = " << employee1.eName << "\n";
cout << "Base Pay................. = " << employee1.ePay << "\n";
cout << "Hours in Overtime........ = " << employee1.eOvertimeHours << "\n";
cout << "Overtime Pay Amount...... = " << employee1.eOvertimePay << "\n";
cout << "Total Pay................ = " << employee1.eTotalPay << "\n\n";

cout << "Employe Name ............ = " << employee2.eName << "\n";
cout << "Base Pay................. = " << employee2.ePay << "\n";
cout << "Hours in Overtime........ = " << employee2.eOvertimeHours << "\n";
cout << "Overtime Pay Amount...... = " << employee2.eOvertimePay << "\n";
cout << "Total Pay................ = " << employee2.eTotalPay << "\n\n";

cout << "Employe Name ............ = " << employee3.eName << "\n";
cout << "Base Pay................. = " << employee3.ePay << "\n";
cout << "Hours in Overtime........ = " << employee3.eOvertimeHours << "\n";
cout << "Overtime Pay Amount...... = " << employee3.eOvertimePay << "\n";
cout << "Total Pay................ = " << employee3.eTotalPay << "\n\n";

cout << "*******************************************************\n";
cout << "*****************EMPLOYEE SUMMARY DATA*****************\n";
cout << "*******************************************************\n";
cout << "** Total Employee Salaries............ " <<   "**\n";
cout << "** Total Employee Hours............... " <<   "**\n";
cout << "** Total Overtime Hours............... " <<   "**\n";
cout << "*******************************************************\n";
    cout << "*******************************************************\n";


return 0;
}

Hey Guys, Thanks for the help. I have most of it done now. It is displaying all the information. I am now just working on getting it to display the Employee Summary Data. I revamped my code to make it cleaner because I was trying every suggestion given to me as I learn best by hands on.

  • 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-06-09T20:39:51+00:00Added an answer on June 9, 2026 at 8:39 pm

    That’s what you get for using non-initialized variables. You have set no value to your class members, you can’t expect the compiler to guess what is your employee’s name or total pay.

    You need to use the form:

    object name.member name = value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are a couple of problems i'm having with this - the first is
So I'm having a couple of problems actually. The first is that I want
I am having a couple problems with the code from the tutorial: ListView Tutorial
I'm using XSLT and having great success, just got a couple of problems. Warning:
I've been making an image uploader and I'm having a couple of issues. Code
I am having problems with my JScript code. I am trying to loop through
I'm having a couple problems and I think they are all somewhat interconnected. brief
I've been going at this problem for a solid couple hours now and having
After having a couple of issues getting DQS installed , it appears to be
I'm having a couple of issues which may be related, or may not. I

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.