使用Java中

时间:2017-12-08 23:25:59

标签: java

新程序员

我目前正试图在星期五晚上享受一点乐趣并制作一个快速计算器来展示梦幻足球比分并且它不会起作用

import java.util.Scanner;
public class Players {

    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    // Prompt user to enter how many catches
    System.out.print("How many catches did the player have? ");
    int catches = input.nextInt();


    //Prompts user to enter how many receiving yards
    System.out.print("How many yards receiving did the player have? ");
    int recYards = input.nextInt();

    //Prompts user to enter how many rushing yards
    System.out.print("How many yards rushing did the player have? ");
    int rushYards = input.nextInt();


    //Prompts user to enter how many touchdowns  
    System.out.print("How many touchdowns did the player have? ");
    int touchDowns = input.nextInt();


    **//Calculates score
    int points = (catches + (recYards % 10) + (rushYards % 10) + (touchDowns * 6));**  


    // Shows score 
    System.out.print("Your score is " + points );

    }

}

我对问题部分加粗了问题。

例如,它给我这样的分数

玩家有多少次捕获? 10 (这应该是10分) 这个玩家有多少码接收? 100 (这应该是10分) 玩家有多少码冲? 50 (这应该是5分) 玩家有多少次达阵? 2 (这应该是12分) 你的分数是22.0 (这应该是37分)

有人可以帮助解释这里出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

我认为你将模%/除以{。}。 Modulus为您提供除法的剩余部分。因此,例如,12 mod 10等于2.