Please help me..I've been working on this nonstop and i still cant get this to run the way i want it to.I am new to programming. i am not very good at using methods. i have a sample of my work here and my problem is how do i get the average of the grades and how do i print it on the console. when i run this code the last values inside the variable grade are the only values that display on the console. I also need to check the attendance...how do i do it?
i need this code for my finals.
package studentmonitoring;
import 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 input=new Scanner(System.in);
int check=0,num=0;
System.out.println(line);
System.out.println(" ****STUDENT MONITORING****");
System.out.println(line);
System.out.println("
Good day teacher, to start using this program input the following information first.
");
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 Name GENDER ADDRESS");
for(int x=0;x<numberStudents;x++) {
System.out.println(idNum1[x]+" "+name1[x]+" "+name2[x]+","+name3[x]+". "+gender[x]+" "+address[x]);
}
System.out.println("Subject Grades");
for(int x=0;x<numSub;x++) {
System.out.println(sub[x]+" "+grade[x]);
}
System.out.println(line);
System.out.println();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…