Declare an array of 25 student scores in a test. Fill the array with random numbers between 1 and 100.
Get the average of all marks.
get the average of all students who scored an ‘A’ grade: 80% or over.
how do i write this program
Printable View
Declare an array of 25 student scores in a test. Fill the array with random numbers between 1 and 100.
Get the average of all marks.
get the average of all students who scored an ‘A’ grade: 80% or over.
how do i write this program
Start here (link below)
The Java™ Tutorials
If you still need help, read this before asking again: (link below)
How To Ask Questions The Smart Way
db
See this post for how to make multi-dimension ArrayLists: Multi Dimensional ArrayList example
For a beginning, I think you just need a Student class with name, score and grade attributes. Then, you can define an arraylist of Student with a length of 25. Prompt for student name, use the java.util.Random class to generate a random score for the students, test whether the score generated is more than 80, etc, and assign the relevant score. Add this student to the arraylist. Something like this:
Code :public class Student { private String name; private int score; private char score; public void setName( String name ) { this.name = name; } public String getName() { return name; } public void setScore( int score ) { this.score = score; } public int getScore() { return score; } public void setGrade( char grade ) { this.grade = grade; } public char getGrade() { return grade; } public void main( String[] args ) { List<Student> students = new ArrayList<Student>(); int i = 0; while( i < 25 ) { // Generate your scores and grades here } } }
I hope this helps.