Java 如何将数组添加到数组中?

Java 如何将数组添加到数组中?,java,arrays,eclipse,Java,Arrays,Eclipse,我设法把考试和功课的分数加起来,得到了平均分。我意识到这是必须发生的 computed module mark = ((coursework mark * coursework weighting) + (examination mark * (100 - coursework weighting))) / 100 所以,我需要制作2个数组(如果我是正确的),每个数组都有每个模块的权重,然后进行这些计算。如何将数组添加到已存在的数组中? 这就是我到目前为止所做的: public static

我设法把考试和功课的分数加起来,得到了平均分。我意识到这是必须发生的

computed module mark = ((coursework mark * coursework weighting) + (examination mark * (100 - coursework weighting))) / 100
所以,我需要制作2个数组(如果我是正确的),每个数组都有每个模块的权重,然后进行这些计算。如何将数组添加到已存在的数组中? 这就是我到目前为止所做的:

public static void main (String [] args)
{
    computeResults();
}
public static void part1 (){

    double examMarks [] = {50,40,60,80,70,11};
    double courseworkmarks [] = {65,49,58,77,35,40};

    System.out.println ("These are the exam marks and the course work marks");//First row is the exam marks, second row is the course work marks
    computeMarks (examMarks);
    computeMarks1 (courseworkmarks);

}
public static void computeMarks(double[] examMarks)
{
    for (int row=0;row<examMarks.length;row++){
            System.out.print (examMarks[row] +"\t");
        }
    System.out.println();
    }
public static void computeMarks1(double[] courseworkmarks)
{
    for (int row=0;row<courseworkmarks.length;row++){
            System.out.print (courseworkmarks[row] +"\t");
        }
    System.out.println();
    }
public static void computeResults()
{
     double examMarks [] = {50,40,60,80,70,11};
        double courseworkmarks [] = {65,49,58,77,35,40};

        double avgMarks[] =new double[examMarks.length];

        for(int i=0;i<avgMarks.length;i++){
            avgMarks[i]=(examMarks[i]+courseworkmarks[i])/2;

        System.out.println(avgMarks[i]);
        }
}
publicstaticvoidmain(字符串[]args)
{
计算机结果();
}
公共静态无效第1部分(){
双examMarks[]={50,40,60,80,70,11};
双程作业分数[]={65,49,58,77,35,40};
System.out.println(“这些是考试分数和课程作业分数”);//第一行是考试分数,第二行是课程作业分数
计算机标记(examMarks);
计算机成绩1(课程成绩);
}
公共静态无效计算标记(双[]个examMarks)
{

对于(int row=0;row来说,最好是这样:

public static void main (String [] args)
{
    double examMarks [] = {50,40,60,80,70,11};
    double courseworkmarks [] = {65,49,58,77,35,40};
    System.out.println ("These are the exam marks and the course work marks");//First row is the exam marks, second row is the course work marks
    computeMarks (examMarks);
    computeMarks1 (courseworkmarks);
    System.out.println ("These are the final marks");
    computeResults(examMarks, courseworkmarks);
}

public static void computeMarks(double[] examMarks)
{
    for (int row=0;row<examMarks.length;row++){
            System.out.print (examMarks[row] +"\t");
        }
    System.out.println();
    }
public static void computeMarks1(double[] courseworkmarks)
{
    for (int row=0;row<courseworkmarks.length;row++){
            System.out.print (courseworkmarks[row] +"\t");
        }
    System.out.println("\n");
    }


public static void computeResults(double[] examMarks, double[] courseworkmarks)
{

        double avgMarks[] =new double[examMarks.length];

        for(int i=0;i<avgMarks.length;i++){
        int cwWeighting=40;
            avgMarks[i]=(examMarks[i]*(100-cwWeighting)+courseworkmarks[i]*cwWeighting)/100;

        System.out.print (avgMarks[i] +"\t");
        }
}
publicstaticvoidmain(字符串[]args)
{
双examMarks[]={50,40,60,80,70,11};
双程作业分数[]={65,49,58,77,35,40};
System.out.println(“这些是考试分数和课程作业分数”);//第一行是考试分数,第二行是课程作业分数
计算机标记(examMarks);
计算机成绩1(课程成绩);
System.out.println(“这些是最终标记”);
计算机成绩(考试成绩、课程成绩);
}
公共静态无效计算标记(双[]个examMarks)
{

对于(int row=0;row我认为您在
computers
的最后一个
for
循环中正确地添加了两个数组。您面临的问题是什么?您是否得到了一些错误?或者意外的结果?我得到了所有数组的平均值,而不是总数,然后返回每个数组,现在我需要得到总数,将所有6个数组相加租用结果并生成100分的结果,例如全年的总分数1更多问题,我有没有办法为我拥有的2个数组设置一条捷径?就像第1部分和computeMarks方法。有没有办法设置一条捷径?因此,当我需要更改分数时,我不必同时更改这两条?(只需在这个线程上回答)你是说你想从一个文件或什么的地方阅读它们吗?如果是的话,那完全是一个新问题,你可能想把它作为一个新问题发布,或者看看这个网站上已经存在的大量类似问题。谢谢,那太好了。这使它变得更简单、更整洁:Di在再次感谢你的帮助。还有一件事,很抱歉再次打扰你。