[说明]
现需要统计某企业员工的月平均:[资,即该企业本月发给员工的工资总和除以员工数。假设企业本月发给员工的工资总和为sumSalary,该企业的员工总数为employeeNumber,下面的程序代码计算该企业员工本月的平均工资,其中需要处理employNumber为0的情况。
[C++代码]
#include
using namespace std;
class Department
protected:
float average(float x, int y)
if(Y==O) throw (1) ;
return x/y;
public:
void caculate(void)
float sumSalary;
int employeeNumber;
try
cout <<"请输入当月工资总和与员工数:"<<endl;
cin >> sumSalary >> employeeNumber:
float k=average(sumSalary,employeeNumber);
cout <<"平均工资:"<<k<<endl;
(2) (int e)
if(e==0)
cout <<"请重新输入当月工资总和与员工数:"<<endl;
cin>>sumSalary>>employeeNumber;
float k=average(sumSalary,employeeNumber);
cout<<"平均工资:"<<k<<endl;
;
VOid msin( )
try
(3) ;<
[说明]
现需要统计某企业员工的月平均工资,即该企业本月发给员工的工资总和除以员工人数。假设企业本月发给员工的工资总和为sumSalary,该企业的员工总数为employeeNumber,下面的程序代码计算该企业员工本月的平均工资,其中需要处理employNumber为0的情况。
[Java代码]
import Java.util.Scanner;
public class JavaMain
static float average(float X,int Y)throws Exception
if(Y==0)throw new Exception( (1) );
return X/Y;
Static Void caculate( )throws Exception
float sumSalary;
int employeeNumber;
Scanner SC=new Scanner( (2) );
try
System.out.println("请输入当月工资总和与员工数:");
sumSalary=sc.nextFloat( ); //从标准输入获得工资总和
employeeNumber=SC.nextInt( ); //从标准输入获得员工数
float k=average(sumSalary,employeeNumber);
System.out.println("平均工资:"+k);
(3) (Exception e)
if(e.getMeSSage( ).equalSIgnoreCase("zero"))
System.out.println("请重新输入当月工资总和与员工数:");
sumSalary=sc.nextFloat( );
emp
[说明]
现需要统计某企业员工的月平均:[资,即该企业本月发给员工的工资总和除以员工数。假设企业本月发给员工的工资总和为sumSalary,该企业的员工总数为employeeNumber,下面的程序代码计算该企业员工本月的平均工资,其中需要处理employNumber为0的情况。
[C++代码]
#include
using namespace std;
class Department
protected:
float average(float x, int y)
if(Y==O) throw (1) ;
return x/y;
public:
void caculate(void)
float sumSalary;
int employeeNumber;
try
cout <<"请输入当月工资总和与员工数:"<<endl;
cin >> sumSalary >> employeeNumber:
float k=average(sumSalary,employeeNumber);
cout <<"平均工资:"<<k<<endl;
(2) (int e)
if(e==0)
cout <<"请重新输入当月工资总和与员工数:"<<endl;
cin>>sumSalary>>employeeNumber;
float k=average(sumSalary,employeeNumber);
cout<<"平均工资:"<<k<<endl;
;
VOid msin( )
try
(3) ;<
我来回答: