如何在java中的每一列下添加我的值? [英] How do I add my values under each column in java?

查看:43
本文介绍了如何在java中的每一列下添加我的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,用户需要将5个学生评估结果输入到一个数组中,如何使结果显示在每个列和行下的一个表中。



我尝试过:



公共类审查{

扫描仪输入=新扫描仪(System.in);

String TeacherName;

int RatesArray [] [] = new int [5] [5];

int [] numbers = new int [5];

int Assessment1,Assessment2,Assessment3,Assessment4,Assessment5;

public int [] RateArray()

{

System.out.println(费率为:);

System.out.println(输入所有评估标记);



for(int row = 0; row< numbers.length; row ++)

{

for(int col = 0; col< numbers.length; col ++)

{

RatesArray [row] [col] = input.nextInt();

} <无线电通信/>


}

返回数字;

}

public void ShowAll()

{

RateArray();



for(int row = 0; row< numbers.length; row ++)

{

System.out.println(Assessment1,Assessment2,Assessmnt3,Assessmnt4,Assessmnt5);

System.out.println(学生1:);

System.out.println(学生2:);

System.out.println( 学生3:);

System.out.println(学生4:);

System.out.println(学生5:);

for(int col = 0; col< 5; col ++)

{

System.out.print(RatesArray [row] [col] +);

}

System.out.println();

}

}

i have a program where the user need to input 5 student assessment results into an array, How do i make that the results be displayed in one table under each column and row.

What I have tried:

public class Vetting {
Scanner input = new Scanner(System.in);
String TeacherName;
int RatesArray[][] = new int [5][5];
int[] numbers= new int[5];
int Assessment1,Assessment2,Assessment3,Assessment4,Assessment5;
public int [] RateArray()
{
System.out.println("The rates are: ");
System.out.println("Enter all Assessment marks");

for(int row =0; row<numbers.length;row++)
{
for(int col = 0; col<numbers.length;col++)
{
RatesArray[row][col] = input.nextInt();
}

}
return numbers;
}
public void ShowAll()
{
RateArray();

for(int row = 0; row<numbers.length;row++)
{
System.out.println("Assessment1, Assessment2, Assessmnt3, Assessmnt4, Assessmnt5");
System.out.println("Student 1: ");
System.out.println("Student 2: ");
System.out.println("Student 3: ");
System.out.println("Student 4: ");
System.out.println("Student 5: ");
for(int col = 0; col<5;col++)
{
System.out.print(RatesArray[row][col]+ " ");
}
System.out.println(" ");
}
}

推荐答案

使用空格或制表符。但最好还是使用格式模板:格式化数字打印输出(The Java™Tutorials) [ ^ ]
Use spaces or tabs. But better still use format templates: Formatting Numeric Print Output (The Java™ Tutorials)[^]


这篇关于如何在java中的每一列下添加我的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆