2017-10-23 12 views
0

他のメソッドを呼び出そうとするとこのエラーが発生します。私はそれが必要なのでメソッドのオーバーロードを使用しようとしています。 私は計算が正しいことを知っています。私はちょうど彼らの値に基づいてメッセージを印刷する最終的なgpa値を取得したいです。StudentGPA.java:5:エラー: '.class'の予想エラー

私はちょうど方法GPA電卓を呼び出すと、Mainメソッド

import java.util.Scanner; 
public class StudentGPA { 

public static void main(String[] args){ 
    gpaCalculator(double gpa); 
    double gpa; 

    if (gpa == 4.0){ 
     System.out.println("Excellent! Congratulations on a great job!"); 
    } 

    else if ((gpa >= 3.5)&&(gpa < 4.0)){ 
     System.out.println("Great job! Keep up the good work!"); 
    } 

    else if ((gpa >= 3.0)&&(gpa <3.5)){ 
     System.out.println("Very good job! Make sure you keep it this way(or higher) to easily get to graduate school"); 
    } 

    else if ((gpa >= 2.0)&&(gpa <3.0)){ 
     System.out.println("Time to put a little more effort not to fall below 2.0 and most importantly to get back to 3.0"); 
    } 
    else if (gpa < 2.0){ 
     System.out.println("I'm sure you'll get back on track, but please make an appointment with an advisor!"); 
    } 
    else{ 
     return; 
    } 


} 
public static void gpaCalculator(double gpa){ 

String grade = ""; 
double credit1; 
double credit2; 
double credit3; 
double credit4; 
double gradeValue=0; 
double totPtsClass1=0; 
double totPtsClass2=0; 
double totPtsClass3=0; 
double totPtsClass4=0; 
double totPts=0; 
double totalCredits= 0; 


Scanner scrn = new Scanner (System.in); 
    System.out.println("Please enter the number of credits of the class 1  (A number)"); 
    credit1 = scrn.nextDouble(); 
    System.out.println("Please enter your grades for the class 1(Capital letters such as A,B+, C-)"); 
    grade = scrn.next(); 

    if (grade.equals ("A")) 
    gradeValue= 4.00; 
    else if (grade.equals("A-")) 
    gradeValue= 3.67; 
    else if (grade.equals("B+")) 
    gradeValue = 3.33; 
    else if (grade.equals("B")) 
    gradeValue = 3.00; 
    else if (grade.equals ("B-")) 
    gradeValue = 2.67; 
    else if (grade.equals("C+")) 
    gradeValue = 2.33; 
    else if (grade.equals("C")) 
    gradeValue = 2.00; 
    else if (grade.equals ("D+")) 
    gradeValue = 1.33; 
    else if (grade.equals ("D")) 
    gradeValue = 1.00; 
    else if (grade.equals ("F")) 
    gradeValue = 0; 
    else if (grade.equals ("FX")) 
    gradeValue = 0; 
    else 
    System.out.println ("Invalid Grade"); 

    totPtsClass1 = gradeValue * credit1; 

    System.out.println("Please enter the number of credits of the class 2 (A number)"); 
    credit2 = scrn.nextDouble(); 
    System.out.println("Please enter your grades for the class 2 (Capital letters such as A,B+, C-)"); 
    grade = scrn.next(); 

    if (grade.equals ("A")) 
    gradeValue= 4.00; 
    else if (grade.equals("A-")) 
    gradeValue= 3.67; 
    else if (grade.equals("B+")) 
    gradeValue = 3.33; 
    else if (grade.equals("B")) 
    gradeValue = 3.00; 
    else if (grade.equals ("B-")) 
    gradeValue = 2.67; 
    else if (grade.equals("C+")) 
    gradeValue = 2.33; 
    else if (grade.equals("C")) 
    gradeValue = 2.00; 
    else if (grade.equals ("D+")) 
    gradeValue = 1.33; 
    else if (grade.equals ("D")) 
    gradeValue = 1.00; 
    else if (grade.equals ("F")) 
    gradeValue = 0; 
    else if (grade.equals ("FX")) 
    gradeValue = 0; 
    else 
    System.out.println ("Invalid Grade"); 

    totPtsClass2 = gradeValue * credit2; 

    System.out.println("Please enter the number of credits of the class 3 (A number)"); 
    credit3 = scrn.nextDouble(); 
    System.out.println("Please enter your grades for the class 3 (Capital letters such as A,B+, C-)"); 
    grade = scrn.next(); 

    if (grade.equals ("A")) 
    gradeValue= 4.00; 
    else if (grade.equals("A-")) 
    gradeValue= 3.67; 
    else if (grade.equals("B+")) 
    gradeValue = 3.33; 
    else if (grade.equals("B")) 
    gradeValue = 3.00; 
    else if (grade.equals ("B-")) 
    gradeValue = 2.67; 
    else if (grade.equals("C+")) 
    gradeValue = 2.33; 
    else if (grade.equals("C")) 
    gradeValue = 2.00; 
    else if (grade.equals ("D+")) 
    gradeValue = 1.33; 
    else if (grade.equals ("D")) 
    gradeValue = 1.00; 
    else if (grade.equals ("F")) 
    gradeValue = 0; 
    else if (grade.equals ("FX")) 
    gradeValue = 0; 
    else 
    System.out.println ("Invalid Grade"); 

    totPtsClass3 = gradeValue * credit3; 

    System.out.println("Please enter the number of credits of the class 4 (A number)"); 
    credit4 = scrn.nextDouble(); 
    System.out.println("Please enter your grades for the class 4 (Capital letters such as A,B+, C-)"); 
    grade = scrn.next(); 

    if (grade.equals ("A")) 
    gradeValue= 4.00; 
    else if (grade.equals("A-")) 
    gradeValue= 3.67; 
    else if (grade.equals("B+")) 
    gradeValue = 3.33; 
    else if (grade.equals("B")) 
    gradeValue = 3.00; 
    else if (grade.equals ("B-")) 
    gradeValue = 2.67; 
    else if (grade.equals("C+")) 
    gradeValue = 2.33; 
    else if (grade.equals("C")) 
    gradeValue = 2.00; 
    else if (grade.equals ("D+")) 
    gradeValue = 1.33; 
    else if (grade.equals ("D")) 
    gradeValue = 1.00; 
    else if (grade.equals ("F")) 
    gradeValue = 0; 
    else if (grade.equals ("FX")) 
    gradeValue = 0; 
    else 
    System.out.println ("Invalid Grade"); 
    totPtsClass4 = gradeValue * credit4; 

    totPts= totPtsClass1+totPtsClass2+totPtsClass3+totPtsClass4; 
    totalCredits = credit1+credit2+credit3+credit4; 
    gpa= totPts/totalCredits; 

    return gpa; 
    } 
} 
+0

gpaCalculator(double gpa); double gpa; 

を変更、それを呼び出すために、

public static double gpaCalculator(){ 

そしてべきである(見たことがない人あなたのコードを前に)あなたがprobleを再現できるように十分に含めることができたらm。参照:[最小限で完全で検証可能な例の作成方法](https://stackoverflow.com/help/mcve) –

+0

申し訳ありませんが、主な目的は学生のGPAに基づいてメッセージを印刷することです。私は複数の方法を使用する必要があります –

答えて

1

あなたは構文エラーの数を持って、それを配置する複数のメソッドを使用する方法を理解するために私を助けてください、のは、固定することから始めてみましょうメソッド。この

public static void gpaCalculator(double gpa){ 

は、それが私たちのために役立つだろう

double gpa = gpaCalculator(); 
関連する問題