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
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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:
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.