나는 재미있는 간단한 등급 시스템을 만들었습니다. 총 성적을 적용하고 내 getApercent()
방법의 방정식에 추가하려고합니다. 그러나, 나는 오류를 계속하고 무엇을 해야할지 모르겠다.다른 메서드에서 다른 메서드로 결과를 얻는 방법 java?
package gradesystem;
import java.util.Scanner;
public class Gradesystem {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
Gradesystem gs = new Gradesystem();
// TODO Auto-generated method stub
int Acount,Bcount,Ccount,Dcount,Fcount;
double ap,bp,cp,dp,fp;
System.out.println("Enter the amount of A's");
Acount = keyboard.nextInt();
System.out.println("Enter the amount of B's");
Bcount = keyboard.nextInt();
System.out.println("Enter the amount of C's");
Ccount = keyboard.nextInt();
System.out.println("Enter the amount of D's");
Dcount = keyboard.nextInt();
System.out.println("Enter the amount of F's");
Fcount = keyboard.nextInt();
int grades;
ap = getApercent(Acount);
System.out.println(ap);
bp = getBpercent(Bcount);
System.out.println(bp);
cp = getCpercent(Ccount);
System.out.println(cp);
dp = getDpercent(Dcount);
System.out.println(dp);
fp = getFpercent(Fcount);
System.out.println(fp);
}
public static void Totalgrades(int acount, int bcount, int ccount, int dcount, int fcount){
int totalofgrades = acount + bcount + ccount + dcount + fcount;
System.out.print(totalofgrades);
}
public static double getApercent(int a){
double ap;
ap = (a/a * 100) + 0.5;
return Math.round(ap);
}
public static double getBpercent(int b){
double bp;
bp = (b/b * 100) + 0.5;
return Math.round(bp);
}
public static double getCpercent(int c){
double cp;
cp = (c/c * 100) + 0.5;
return Math.round(cp);
}
public static double getDpercent(int d){
double dp;
dp = (d/d * 100) + 0.5;
return dp;
}
public static double getFpercent(int f){
double fp;
fp = (f/f * 100) + 0.5;
return fp;
}
}
'오류가 계속 발생하고 무엇을 해야할지 모르겠다'... 오류는 무엇인지 결코 말하지 않았기 때문에 우리도 마찬가지입니다. 정확한 문제는 무엇입니까? –
음, a/a는 기본 수학입니다. 결과는 1이됩니다. 10/10 = 1 – darkhouse
Totalgrades 안에 Acount, Bcount 등의 합계를 얻으려고합니다. 내 getApercent() 메소드 내부. 나는이 방법을 시도하고있다 "a/totalgrades() * 100 + 0.5 –