Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 员工工资总额薪资数组_Javascript_Arrays - Fatal编程技术网

Javascript 员工工资总额薪资数组

Javascript 员工工资总额薪资数组,javascript,arrays,Javascript,Arrays,我的任务是创建一个代码,该代码将计算员工的总工资,并限制每小时工资不得低于8美元。我不确定为什么我的代码不会运行,编译时不会显示错误 public static void main(String[] args) { Scanner key = new Scanner(System.in); int numEmployees = key.nextInt(); int employeeName[] = new int[numEmployees]; int hour

我的任务是创建一个代码,该代码将计算员工的总工资,并限制每小时工资不得低于8美元。我不确定为什么我的代码不会运行,编译时不会显示错误

public static void main(String[] args) {

    Scanner key = new Scanner(System.in);

    int numEmployees = key.nextInt();
    int employeeName[] = new int[numEmployees];
    int hoursWorked[] = new int[numEmployees];
    int hourlyWage[] = new int[numEmployees];
    int grossWages[] = new int[numEmployees];

    System.out.println("Enter the number of employess whose gross wages"
            + " you wish to calculate:");
    //user enter employee name

    for(int i = 1; i < employeeName.length; i++)
    {
        System.out.println("Enter name of employee " + i+ ":");
        employeeName[i]= key.nextInt();
        i++;
    }

    //user enters number of hours
    //System.out.println("How many hours did" + employeeName[i] + " work this week?");

    for(int i = 0; i< numEmployees; i++)
    {
        System.out.print("How many hours did" + employeeName[i] + " work this week?");
        hoursWorked[i] = key.nextInt();

        //get the hourly pay rate
        System.out.print("What is" + employeeName[i] + " hourly wage?");
        //hourlyWage = key.nextInt();

        grossWages[i] = hoursWorked[i] * hourlyWage[i];
    }
    //displays wages
    System.out.println("The hours and pay rates you entered are:");

    for(int i = 0; i < numEmployees; i++)
    {
        //hourlyWage = key.nextInt();
        System.out.printf("The total wages for Employee #%d is $%.2f\n", employeeName[i], hourlyWage);
    }

    //System.out.print("");
    //System.out.print("Name     Hours Worked     Hourly Pay Rate     Gross Wages Earned");
    //System.out.println(employeeName + "     " + hoursWorked + "     " + hourlyWage + "     " + grossWages);
publicstaticvoidmain(字符串[]args){
扫描仪键=新扫描仪(System.in);
int numEmployees=key.nextInt();
国际雇员姓名[]=新国际雇员人数;
int hoursweed[]=新的int[numememployees];
int hourlyWage[]=新的int[numememployees];
国际总工资[]=新国际总工资[numEmployees];
System.out.println(“输入其总工资的雇员人数”
+“您希望计算:”;
//用户输入员工姓名
for(int i=1;i
} }

1)接受输入前提示

System.out.println("Enter the number of employess whose gross wages"
        + " you wish to calculate:");
然后

2) 从零开始循环

for(int i = 1; i < employeeName.length; i++)
编辑

为什么员工姓名是一个
int

公共静态void main(字符串[]args){

Scanner key=新扫描仪(System.in);
int numEmployees=key.nextInt();
国际雇员姓名[]=新国际雇员人数;
int hoursweed[]=新的int[numememployees];
int hourlyWage[]=新的int[numememployees];
国际总工资[]=新国际总工资[numEmployees];
System.out.println(“输入其总工资的雇员人数”
+“您希望计算:”;
//用户输入员工姓名
for(int i=1;i

}}

Java之于Javascript,犹如痛苦之于绘画,火腿之于汉普斯特。他们完全不同。强烈建议有抱负的代码者尝试学习他们试图写入代码的语言的名称。当你发布一个问题时,请适当地标记它。这很有趣@CertainPerformance,特别是“痛苦在于绘画”,我要偷,我的意思是使用它-这特别有趣,因为javascript标记声明不要与Java混淆。请不要只发布代码答案,请解释你做了什么。
for(int i = 1; i < employeeName.length; i++)
//hourlyWage = key.nextInt();
Scanner key = new Scanner(System.in);

int numEmployees = key.nextInt();
int employeeName[] = new int[numEmployees];
int hoursWorked[] = new int[numEmployees];
int hourlyWage[] = new int[numEmployees];
int grossWages[] = new int[numEmployees];

System.out.println("Enter the number of employess whose gross wages"
        + " you wish to calculate:");
//user enter employee name

for(int i = 1; i < employeeName.length; i++)
{
    System.out.println("Enter name of employee " + i+ ":");
    employeeName[i]= key.nextInt();
    i++;
}

//user enters number of hours
//System.out.println("How many hours did" + employeeName[i] + " work this week?");

for(int i = 0; i< numEmployees; i++)
{
    System.out.print("How many hours did" + employeeName[i] + " work this week?");
    hoursWorked[i] = key.nextInt();

    //get the hourly pay rate
    System.out.print("What is" + employeeName[i] + " hourly wage?");
    hourlyWage[i] = key.nextInt();

    grossWages[i] = hoursWorked[i] * hourlyWage[i];
}
//displays wages
System.out.println("The hours and pay rates you entered are:");

for(int i = 0; i < numEmployees; i++)
{
    //hourlyWage = key.nextInt();
    System.out.printf("The total wages for Employee #%d is $%.2f\n", employeeName[i], hourlyWage[i]);
}

//System.out.print("");
//System.out.print("Name     Hours Worked     Hourly Pay Rate     Gross Wages Earned");
//System.out.println(employeeName + "     " + hoursWorked + "     " + hourlyWage + "     " + grossWages);