
Hi Everyone,
I have a assignment that requires me to a write simple java program that will calculate marks for 10 students. I must use an array to ask user to key in the marks for the 10 students. The marks consist of two tests, test 1 and test 2. I also need to calculate and find the best students and also the weak students. The name of the students are declared in the array consisting of 5 boys and 5 girls.
I have no idea of how to do this. Please someone help me with this assignment.
Thank you very much.

import java.util.*;
class Assignment
{
String name;
int totalMarks;
Assignment(String name, int totalMarks){
this.name=name;
this.totalMarks=totalMarks;
}
public String getName(){
return name;
}
public int getTotalMarks(){
return totalMarks;
}
public static void main(String[] args)
{
ArrayList<Assignment> list=new ArrayList<Assignment>();
String names[]=new String[4];
int marks[]=new int[4];
Scanner input=new Scanner(System.in);
for(int i=0;i<marks.length;i++){
System.out.print("Enter Name:");
String n=input.next();
System.out.print("Enter marks in test1:");
int t1=input.nextInt();
System.out.print("Enter marks in test2:");
int t2=input.nextInt();
int m=t1+t2;
names[i]=n;
marks[i]=m;
list.add(new Assignment(names[i],marks[i]));
}
int lowest = marks[0];
int highest = marks[0];
for(int i=1; i< marks.length; i++)
{
if(marks[i] > highest)
highest = marks[i];
else if (marks[i] < lowest)
lowest = marks[i];
}
for(Assignment a: list){
if(a.getTotalMarks()==highest){
System.out.println(a.getName() + " get the highest marks");
}
if(a.getTotalMarks()==lowest){
System.out.println(a.getName() + " get the lowest marks");
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.