Bitte helfen Sie mir..Ich habe an diesem nonstop gearbeitet und ich kann immer noch nicht so laufen, wie ich es will.Ich bin neu in der Programmierung. Ich bin nicht sehr gut darin, Methoden anzuwenden. Ich habe hier eine Probe meiner Arbeit und mein Problem ist, wie bekomme ich den Durchschnitt der Noten und wie drucke ich es auf der Konsole. Wenn ich diesen Code ausführe, sind die letzten Werte innerhalb der Variablenklasse die einzigen Werte, die auf der Konsole angezeigt werden. Ich muss auch die Anwesenheit überprüfen ... wie mache ich das? Ich brauche diesen Code für mein Finale.Wie berechnet man die Durchschnittsnote der Werte von einem Array?
Paket studentmonitoring;
importieren java.util. *; public class StudentMonitoring {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
Date date=new Date();
int[] attend1={},attend2,attend3,grade={};
String line="-------------------------------------------------------------------";
String[] idNum1={},idNum2={},gender={}, name1={},name2={},name3={},name4={},address={},sub={};
Scanner Eingang = new Scanner (System.in); int check = 0, num = 0;
System.out.println(line);
System.out.println("\t\t****STUDENT MONITORING****");
System.out.println(line);
System.out.println("\nGood day teacher, to start using this program input the following information first.\n");
System.out.println(line);
System.out.print("NAME OF SCHOOL: ");
String sName=in.nextLine();
System.out.print("ADDRESS OF SCHOOL: ");
String sAdd=in.nextLine();
System.out.print("SCHOOL IDENTIFICATION NUMBER: ");
String sId=in.nextLine();
System.out.println(line);
System.out.println("STUDENTS INFORMATION");
System.out.println("Enter the year and section of this class");
String yearSec=in.nextLine();
System.out.println("How many student information do you want to input? ");
int numberStudents=in.nextInt();
idNum1=new String[numberStudents];
name1=new String[numberStudents];
name2=new String[numberStudents];
name3=new String[numberStudents];
name4=new String[numberStudents];
attend1=new int[200];
attend2=new int[200];
attend3=new int[200];
address=new String[numberStudents];
grade=new int[100];
gender=new String[numberStudents];
idNum2=new String[numberStudents];
System.out.println("Enter the number of subjects you have: ");
int numSub=in.nextInt();
sub=new String[numSub];
in.nextLine();
for(int x=0;x<numSub;x++) {
System.out.print("SubjeC#"+(x+1)+": ");
sub[x]=in.nextLine();
}
for(int x=0;x<numberStudents;x++) {
in.nextLine();
System.out.println(line);
System.out.println("Student #"+(x+1));
System.out.print("LAST NAME: ");
name1[x]=in.nextLine();
System.out.print("FIRST NAME: ");
name2[x]=in.nextLine();
System.out.print("MIDDLE INITIAL: ");
name3[x]=in.nextLine();
System.out.print("GENDER: ");
gender[x]=in.nextLine();
System.out.print("ADDRESS: ");
address[x]=in.nextLine();
System.out.print("ID NUMBER: ");
idNum1[x]=in.nextLine();
System.out.println(line);
System.out.println("Enter the grades here.");
System.out.println(line);
for (int a=0;a<numSub;a++) {
System.out.print(sub[a]+": ");
grade[a]=in.nextInt();
}
}
System.out.println("This is the list of the students info you've inputted.");
System.out.println("ID Number\t Name\t\t GENDER\t\t ADDRESS");
for(int x=0;x<numberStudents;x++) {
System.out.println(idNum1[x]+"\t\t"+name1[x]+" "+name2[x]+","+name3[x]+".\t\t"+gender[x]+"\t\t"+address[x]);
}
System.out.println("Subject\t\tGrades");
for(int x=0;x<numSub;x++) {
System.out.println(sub[x]+"\t\t"+grade[x]);
}
System.out.println(line);
System.out.println();
}
}
Dieses parallele Array-Design ist nicht gut. – Enzokie
bitte helfen Sie mir, ein besseres zu machen. – JohnHERE
Wenn Sie bereits in OOP tauchen, sollten Sie diese Dinge als ein Array von Student-Objekten entwerfen, anstatt ein einzelnes Array für jedes Attribut zu erstellen. – Enzokie