它应该返回值70.28,但它返回0.0。我不明白为什么会这样做。方程式已设置。我把它设置在一个方法中,但是我把它拿出来所以我可以保留这些值并在以后使用它们。它在方法内部工作,但现在它不在方法中,它不起作用。
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class Assignment51
{
public static void main(String[] args)
{
/*
Four Categories are used as a basis for compiling a rating:
1. Percentage of completions
2. Average yards gained
3. Percentage of touchdown passes per attempt
4. Percentage of interceptions per attempt
*/
// DecimalFormat formatter = new DecimalFormat("#,##0.000");
String input; //get user input
String name; //player name
int completion; //number of completions in percentages
int yardsGained; //number of yards gained
int tdpasses; //number of touchdown passes
int interceptions; //number of interceptions
int attempts; //number of attempts
int yards; //number of yards
double score; //passer score
double totalScore; //total score
double totalPoints; //total award points
double total; //total sum
double awardPoints1 = 0.0; //awarded points +/- 2.375
double awardPoints2 = 0.0;
double awardPoints3 = 0.0;
double awardPoints4 = 0.0;
double percentComp;
double pointRatingComp;
int num1;
//get player name
name = JOptionPane.showInputDialog("Type in the player name");
//get number of attemps/passes
input = JOptionPane.showInputDialog("Type in the TOTAL number of passes");
attempts = Integer.parseInt(input);
//get number of completed passes
input = JOptionPane.showInputDialog("Type in the number of COMPLETED passes");
num1 = Integer.parseInt(input);
percentComp = ((num1 / attempts) * 100);
//DEBUG
System.out.println(percentComp);
//point rating
pointRatingComp = ((percentComp - 30) * .05);
//Creating Methods
double PctCompletion = PctCompletion(attempts, percentComp);
double AvgYardsGain = AvgYardsGain(attempts);
double PctTouchdown = PctTouchdown(attempts);
double PctInterceptions = PctInterceptions(attempts);