Join 131,690 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,492 people online right now. Registration is fast and FREE... Join Now!
i want to add the finalgrade of prelim of student1, in finalgrade of midterm,prefinals and finals then divided by 4 to get the general average then display the result
and i want to do it in other sutdent
pls help me becuase i dont know how to do it pls again thank you
Are you trying to store the grades for 10 students as the line in your code int[] student={1,2,3,4,5,6,7,8,9,10}; Suggests this to me in some way... if you are then you will need to change all of your grades to arrays and index each students grade... I will do that for you in a general sense and give you an idea how to do it...
The way i would do it is create a class student and set all the scores that way... then a class Semester and store the student scores in that for each student...
This is horrible but it sort of does what i think you are asking
java
import java.util.*;
class GradingSystem { public static void main(String[]args) throws Exception {
/*double Quiz,Attendance,Recitation,Exam, GradeQuiz,GradeAttendance,GradeRecitation, GradeExam,FinalGrade; */ double[] Quiz_array = new double[10]; double[] Attendance_array = new double[10]; double[] Recitation_array = new double[10]; double[] Exam_array = new double[10]; double[] GradeQuiz_array = new double[10]; double[] GradeAttendance_array = new double[10]; double[] GradeRecitation_array = new double[10]; double[] GradeExam_array = new double[10];
// To Input scores for 10 students and print the score as you previously had // for (int i = 0; i < FirstSemester.length; i++) { System.out.println(""); System.out.println("" + FirstSemester[i]);
//now print the student out with their final grade for (int stud = 0; stud < FinalGrade_array.length; stud++) System.out.println("\nStudent : " + stud + "\nFinalGrade =" +FinalGrade_array[i]);
//not that once it reloops... all your stored values will be overwritten... so each semester will overide // the previous semesters scores or grades
}
} //end main }
This post has been edited by bbq: 15 Oct, 2008 - 05:15 AM
Are you trying to store the grades for 10 students as the line in your code int[] student={1,2,3,4,5,6,7,8,9,10}; Suggests this to me in some way... if you are then you will need to change all of your grades to arrays and index each students grade... I will do that for you in a general sense and give you an idea how to do it...
The way i would do it is create a class student and set all the scores that way... then a class Semester and store the student scores in that for each student...
This is horrible but it sort of does what i think you are asking
java
import java.util.*;
class GradingSystem { public static void main(String[]args) throws Exception {
/*double Quiz,Attendance,Recitation,Exam, GradeQuiz,GradeAttendance,GradeRecitation, GradeExam,FinalGrade; */ double[] Quiz_array = new double[10]; double[] Attendance_array = new double[10]; double[] Recitation_array = new double[10]; double[] Exam_array = new double[10]; double[] GradeQuiz_array = new double[10]; double[] GradeAttendance_array = new double[10]; double[] GradeRecitation_array = new double[10]; double[] GradeExam_array = new double[10];
// To Input scores for 10 students and print the score as you previously had // for (int i = 0; i < FirstSemester.length; i++) { System.out.println(""); System.out.println("" + FirstSemester[i]);
//now print the student out with their final grade for (int stud = 0; stud < FinalGrade_array.length; stud++) System.out.println("\nStudent : " + stud + "\nFinalGrade =" +FinalGrade_array[i]);
//not that once it reloops... all your stored values will be overwritten... so each semester will overide // the previous semesters scores or grades
}
} //end main }
sir thank you very much
in my first plan yes but after having alot of problems and get many errors i change my plan and make it simple a program that i think i can make but i was wrong my knowledge in programming is poor but i will not stop
sir im not familiar with scanner and im having problem in line 30 with the scanner i try to import java.util.Scanner; in line 1 but still it wont work and until now im still trying to find how to make it work
again thank you
This post has been edited by tagz12: 15 Oct, 2008 - 08:01 AM
Well its really good you are having a good go at it. Have you covered array's ? Perhaps recode your program from the start.
Make it simple - just ask for 4 inputs (marks) and compute the average grade and print it out. Start off small and build upwards from there.
The Scanner is a part of java.util.*; and it allows you to take in user inputs. You initialise a new scanner
Scanner tagz12 = new Scanner(System.in);
then use various methods to take certain inputs
for example assuming you are using the Scanner called tagz12
int myInt = tagz12.nextInt();
double someDouble = tagz12.nextDouble();
String aName = tagz12.next();
What JDK are you running and what version of it.... Perhaps update to the latest from www.java.sun.com install it and compile with that... are you using command prompt to compile or are you utilising an IDE like Netbeans or Eclipse ?
in command prompt type the following and post back what it says
Firstly type java -version
Then post the output here
Secondly type javac -version
Then post the output here
That will tell you the version of java you are running. JCreator is simply an IDE (Integrated Development Environment) and it relies on the versions of Java that you have installed. So please post the results of that just so we can see whats going on
Just as i though, javac is the command used to compile java code. Whilst java is the command used to execute compiled code. So I have to ask do you have the JDK installed ? Usually from memory in windows it is located in c:\ProgramFiles\Java\jdk_"someversion"
If you do not have the java JDK installed then you will not be able to compile java at all. I wrote a tutorial a while back on setting up java on windows... Perhaps it might help you. Seem as though it is not on this site and is hosted on my own site i will pm you the details. So check your private messages
edit you cant recieve messages yet
QUOTE
Ok mate, i wrote this page a long time ago, however it still applies and should help you get rid of that javac -version command not an external recognized blah blah
Have a look there and read it, it explains how to install the JDK (which is needed) and get java working with cmd prompt
The first thing you should do though is download the Java JDK which you can get from here. Just select your Operating system and download it Download Java JDK
If you have any further questions just contact me
is what i said...
This post has been edited by bbq: 16 Oct, 2008 - 03:14 AM
i did what you say i follow the instruction that you give but sad to say it did not remove the problem in javac -version
C:\>javac -version 'javac' is not recognized as an internal or external command, operable program or batch file.
i dwonload jcreator le v 4.50 and install it in my pc and i try your code and it work but still i cant get the general average of each student
and the problem in javac -version remain here C:\>javac -version 'javac' is not recognized as an internal or external command, operable program or batch file.
thank you
This post has been edited by tagz12: 17 Oct, 2008 - 02:02 AM
JCreator has nothing to do with it. You need to download the sun jdk and install it. That contains all the tools to actually compile code. Read download and install this.