好的,所以我不想让你为我做功课,但是我最后的任务有点迷失,需要我能得到的所有帮助。学习编程很难,但是在线完成它几乎是不可能的......现在,为了进入程序,我将粘贴到目前为止我所拥有的内容。这主要包括//评论和我到目前为止所写的内容。如果你能帮助我找出所有错误的位置以及如何完成任务,我将非常感激。就像我说的,我不希望你为我做功课(这是我的最后一次),但任何建设性的批评都是受欢迎的。这是我上课的最后一个任务,明天到期(亚利桑那州时间午夜之前)。
这是作业:
检查以下情况:
您的公司Datamax,Inc。正在实现薪资系统的自动化。您的经理要求您创建一个计算所有员工加班费的计划。您的计划必须考虑员工的工资,工作总时数和一周工作时间超过40小时,然后提供有用且易于公司管理层理解的输出。
使用以下背景信息和附录D中的代码大纲(包含在代码部分中)编译您的程序。
将您的项目作为附件提交,包括代码和输出。
公司背景:
计划要求:
完成程序的逻辑步骤:
这是代码:
// Final_Project.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//
//CLASS DECLARATION SECTION
//
class CEmployee
{
public:
void ImplementCalculations(string EmployeeName, double hours, double wage);
void DisplayEmployInformation(void);
void Addsomethingup (CEmployee, CEmployee, CEmployee);
string EmployeeName ;
int hours ;
int overtime_hours ;
int iTotal_hours ;
int iTotal_OvertimeHours ;
float wage ;
float basepay ;
float overtime_pay ;
float overtime_extra ;
float iTotal_salaries ;
float iIndividualSalary ;
};
int main()
{ system("cls");
cout << "Welcome to the Employee Pay Center";
/*
Use this section to define your objects. You will have one object per employee. You have only three employees.
The format is your class name and your object name.
*/
std::cout << "Please enter Employee's Name: ";
std::cin >> EmployeeName;
std::cout << "Please enter Total Hours for (EmployeeName): ";
std::cin >> hours;
std::cout << "Please enter Base Pay for(EmployeeName): ";
std::cin >> basepay;
/*
Here you will prompt for the first employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Example of Prompts
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =
*/
/*
Here you will prompt for the second employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =
*/
/*
Here you will prompt for the third employee’s information.
Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above.
Enter the employee name =
Enter the hours worked =
Enter his or her hourly wage =
*/
/*
Here you will implement a function call to implement the employ calcuations for each object defined above. You will do this for each of the three employees or objects.
The format for this step is the following:
[(object name.function name(objectname.name, objectname.hours, objectname.wage)] ;
*/
/*
This section you will send all three objects to a function that will add up the the following information:
- Total Employee Salaries
- Total Employee Hours
- Total Overtime Hours
The format for this function is the following:
- Define a new object.
- Implement function call [objectname.functionname(object name 1, object name 2, object name 3)]
/*
} //End of Main Function
void CEmployee::ImplementCalculations (string EmployeeName, double hours, double wage){
//Initialize overtime variables
overtime_hours=0;
overtime_pay=0;
overtime_extra=0;
if (hours > 40)
{
/*
This section is for the basic calculations for calculating overtime pay.
- base pay = 40 hours times the hourly wage
- overtime hours = hours worked – 40
- overtime pay = hourly wage * 1.5
- overtime extra pay over 40 = overtime hours * overtime pay
- salary = overtime money over 40 hours + your base pay
*/
/*
Implement function call to output the employee information. Function is defined below.
*/
} // if (hours > 40)
else
{
/* Here you are going to calculate the hours less than 40 hours.
- Your base pay is = your hours worked times your wage
- Salary = your base pay
*/
/*
Implement function call to output the employee information. Function is defined below.
*/
} // End of the else
} //End of Primary Function
void CEmployee::DisplayEmployInformation();
{
// This function displays all the employee output information.
/*
This is your cout statements to display the employee information:
Employee Name ............. =
Base Pay .................. =
Hours in Overtime ......... =
Overtime Pay Amount........ =
Total Pay ................. =
*/
} // END OF Display Employee Information
void CEmployee::Addsomethingup (CEmployee Employ1, CEmployee Employ2)
{
// Adds two objects of class Employee passed as
// function arguments and saves them as the calling object's data member values.
/*
Add the total hours for objects 1, 2, and 3.
Add the salaries for each object.
Add the total overtime hours.
*/
/*
Then display the information below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Total Employee Salaries ..... = 576.43
%%%% Total Employee Hours ........ = 108
%%%% Total Overtime Hours......... = 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
} // End of function
答案 0 :(得分:3)
请勿将float
用于财务数据, EVER 。
这将使您进入各种舍入和精度问题,并且您不希望它们在描述金钱总和的数据中。除非你喜欢被起诉,当然:)。
使用整数类型或创建定点类型。
另外,如果可能,请不要使用system()
。这本质上是不可移植的,更不用说缓慢而丑陋了。
在你填写更多代码之前,这就是我可以告诉你的所有内容。祝你好运!