2014-08-31 48 views
0

我正在努力製作一個簡單的成績冊程序。我的代碼還沒有完成,但我想先構造它。我一直得到一個未解決的編譯錯誤,對於我來說我無法弄清楚。我知道這是簡單而愚蠢的事情,但我幾乎是一個新秀。任何幫助試圖克服這個錯誤(Exception in thread "main" java.lang.Error: Unresolved compilation problem: student cannot be resolved to a variable)將不勝感激!Java成績簿程序

import java.util.Scanner; 
public class Gradebook { 

/** 
* @param args 
*/ 
public static void main(String[] args) { 
    // TODO Auto-generated method stub 

    float discussionweight, hwweight, examweight, discussion, hw, exam, finalaverage; 

    // Initializes the input scanner 
    Scanner scan = new Scanner(System.in); 

System.out.print("Enter the students name: "); 
    student = scan.next(""); 

    // Prompts for the weight of the discussions 
    System.out.print ("Enter the weight of the discussions as an integer: "); 
    discussionweight = scan.nextFloat(); 

    // Prompts for the discussions grade 
    System.out.print ("Enter the score of the discussions as an integer: "); 
    discussion = scan.nextFloat(); 

    // Prompts for the weight of the homework grade in an integer 
    System.out.print ("Enter the weight of the homework as an integer: "); 
    hwweight = scan.nextFloat(); 

    // Prompts for hw grade 
    System.out.print ("Enter the hw grade: "); 
    hw = scan.nextFloat(); 

    System.out.print("Enter the weight of the exam as an integer"); 
    examweight = scan.nextFloat(); 

    System.out.print("Enter the exam grade"); 
    exam = scan.nextFloat(); 



    // Calculate and print the final, weighted average. 
    finalaverage = (((discussionweight * discussion) + (hw * hwweight) + (exam * examweight))/100); 

    System.out.println ("The final average is "+ finalaverage); 

    } 

    } 
    } 

} 

回答

0

學生= scan.next( 「」);

你永遠不會告訴編譯器什麼類型的學生。

像字符串學生=掃描...

1

看起來你從來沒有聲明名爲學生變量。

string student = scan.next(""); 

與您正在使用的其他變量相同。