Programme de notes Java


J'essaie de créer un programme de notes simple. Mon code n'est pas encore terminé mais j'essaie de le structurer en premier. Je reçois sans erreur de compilation que pour la vie de moi je ne peux pas comprendre. Je sais que c'est quelque chose de simple et stupide, mais je suis sur que beaucoup d'une recrue comme vous obtenez. Toute aide essayant de surmonter cette erreur (Exception in thread "main" java.lang.Error: Unresolved compilation problem: student cannot be resolved to a variable) serait très appréciée!

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);

    }

    } 
  }

}
Author: matthias_h, 2014-08-31

2 answers

Il semble que vous ne déclarez jamais une variable nommée student.

string student = scan.next("");

Idem pour le reste des variables que vous utilisez.

 1
Author: Ryan Hartman, 2014-08-31 01:25:49

Étudiant = scan.suivant("");

Vous ne dites jamais au compilateur quel type d'étudiant est.

Quelque chose comme String student = scan...

 0
Author: Steve, 2014-08-31 01:25:39