输入和存储字符串在多维数组与用户输入我已经学会了多维数组从谷歌,这是很容易学习,但当我必须实现在任何场景!很难处理。我已经使用用户输入声明了多维数组,现在我想在表中声明这个数组。怎样?
import java.util.Scanner;
public class RugbyProject{
final static int RESULT_POINTS_WIN = 2;
final static int RESULT_POINTS_DRAW = 1;
final static int RESULT_POINTS_LOSS = 0;
final static int GAME_POINTS_TRY = 5;
final static int GAME_POINTS_PENALTY = 3;
final static int GAME_POINTS_DROP_GOAL = 3;
final static int GAME_POINTS_CONVERSATION = 2;
public class Stats {
// TODO Auto-generated method stub
int wins;
int draws;
int losses;
int tries;
int penalties;
int dropgoals;
int conversation;
int totalResultPoints = (wins * RESULT_POINTS_WIN) + (draws * RESULT_POINTS_DRAW) + (losses + RESULT_POINTS_LOSS) + (tries * GAME_POINTS_TRY) +
(penalties * GAME_POINTS_PENALTY) + (dropgoals * GAME_POINTS_DROP_GOAL) + (conversation * GAME_POINTS_CONVERSATION) ;
int averageScorePerMatch = (totalResultPoints/5);
}
public static void main(String args[]){
String teams[] = {"Ireland","England","Scotland","Brazil","Irelan","Romania","Germany"};
System.out.println("Welcome to the six nation ChampionShip");
for(String element : teams){
System.out.println("Enter number of wins, draws and losses for " + element);
Scanner myScanner = new Scanner(System.in);
int [] integer = new int[3];
for(int i = 0; i<3; i++){
integer[i] = myScanner.nextInt();
}
System.out.println("ENter total try count, total penalty count ," + " total dropgoal count total conversation count for " + element);
Scanner myScanner2= new Scanner(System.in);
int[] integers2 = new int[3];
for(int i=0; i<3; i++){
integers2[i] = myScanner2.nextInt();
}
}
}
}
到目前为止,我只是尝试获取输入并存储它。我是java新手,所以我不擅长编程
1条答案
按热度按时间m528fe3b1#
这就是在表中打印数组的答案