合計スコアと重み付きスコアを戻り値にしようとし、パラメータはスキャナコンソールから渡され、戻り値は静的voidメソッド。私はこのプログラムで戻り値を使用しようとしていますが、コンパイルされません
import java.util.*;
public class Grades {
public static void main (String[] args) {
intro();
Scanner console = new Scanner(System.in);
int totalScoreMain = totalScore(score, curveNumber);
double weightedScoreMain = weightedScore(weight, score, curveNumber);
double weightedScore2Main = weightedScore2(weight2, sections, sumScore);
for(int i = 1; i <= 2; exam++); {
System.out.println("Exam i");
exam();
}
homework();
}
public static void intro() {
System.out.println("This program reads exam/homework scores");
System.out.println("and reports your overall course grade.");
System.out.println();
}
public static void exam() {
System.out.print("What is its weight (0-100)?");
double weight = console.nextInt();
System.out.print("Score earned?");
int score = console.nextInt();
System.out.print("Was there a curve (1=yes, 2=no)?");
int curve = console.nextInt();
if (curve == 1) {
System.out.print("How much was the curve?");
int curveNumber = console.nextInt();
} else if (curve == 2) {
int curveNumber = 0;
}
totalScore(score, curveNumber);
weightedscore(weight, score, curveNumber);
System.out.println("Total points = " + totalScoreMain + "/" + "100");
System.out.println("Weighted score = " + weightedScoreMain + "/" + weight);
}
public static int totalScore (int score, int curveNumber) {
int totalScore = Math.min(score + curveNumber, 100);
return totalScore;
}
public static double weightedScore (int weight, int score, int curveNumber) {
double weightedScore = (score + curveNumber) * weight/100;
return weightedScore;
}
public static void homework() {
System.out.print("What is its weight (0-100)?");
int weight2 = console.nextInt();
System.out.print("Number of assignments?");
int number = console.nextInt();
int sumScore = 0;
int sumMax = 0;
for(int i = 1; i <= number; i++) {
System.out.println("Assignment " + i + "score and max?");
int aScore = console.nextInt();
int aScoreMax = console.nextInt();
sumScore = sumScore + aScore;
sumMax = sumMax + aScoreMax; }
System.out.print("How many sections attended?");
int section = console.nextInt();
int sections = Math.min(3 * section, 20);
System.out.println("Section points = " + sections);
weightedScore2(weight2, sections, sumScore);
System.out.println("Total points = " + (sections + sumScore) + "/" + sumMax);
System.out.println("Weighted score = " + weightedScore2 + "/" + weight2);
}
public static double weightedScore2(int weight2, int sections, int sumScore) {
int weightedScore2 = weight2/100 * (sections + sumScore);
return weightedScore2;
}
}
私が間違っていることを理解するのに役立つ人はいますか?私はペーストしたものがなぜ機能していないのか分かりません。
十分な情報に近くない - 何をしますか、何をしないのですか...... – KevinDTimm
コンパイラのエラーメッセージは何ですか? – marc
あなたのコードは本当に感動しません。 _小さな_ステップを試してみて、徐々に何が起こっているのかを理解してください。 – Mat