Java - 将用户输入分配给变量并显示记分板

时间:2017-03-15 20:13:24

标签: java android

我知道它是非常基本的java,但我正在努力学习。有人可以帮助我理解我的错误,我该怎么做才能解决它?

package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int teamA = 0;
        int teamB = 0;


        //asks for the team selection
       System.out.println("Would you like to be in Team A or Tema B? Write A for team A and B for team B");
        Scanner input =  new Scanner(System.in);
        int result = input.nextInt();

        public String scoreBoard() {
            String displayScoreBoard = "No Score";
            if (result.toString == "A" || result.toString == "a"){
                teamA++;
                displayScoreBoard = "Score of TeamX is" + teamA;
            }  else if (result.toString == "B" || result.toString == "b"){
                teamB++;
                displayScoreBoard = "Score of TeamY is" + teamB;
            } System.out.println(displayScoreBoard.toString);
        }


        // write your code here
    }
}

1 个答案:

答案 0 :(得分:0)

你犯了几个错误。例如,您在函数中编写了一个函数。你最好不要这样做。看看我的代码。如果您有任何疑问,请询问;)

更新:由于评论应该有循环,我已经调整了代码。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?q=$1 [QSA,L]