Java中使用变量的初等方程的问题
这里是新程序员 我现在正试图在周五晚上玩得开心一点,然后快速制作一个计算器来显示梦幻足球的分数,但它不会起作用Java中使用变量的初等方程的问题,java,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 Syste
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分)
有人能解释一下这里出了什么问题吗?我想你把模数
%
和除法/
混为一谈了。模数给出除法的剩余部分。例如,12模10等于2。%
是模(余数),/
是除。谢谢,我也不知道为什么有人否决了这条评论。没问题。如果这是正确答案,请将其标记为正确答案,以便其他用户不再回答您的问题。亲切的问候。我没有投反对票,但这可以说是一个打字错误问题,这是结束问题的充分理由,有些人只是对简单问题的所有答案投反对票。