Hello everyone ... am a network associate and dont have much knowledge on java i need to write a program with following requirements
Write a class declaration to do the following operations on the marks of 15 students scored in a subject, stored in an array
1. to find the sum and average of the marks
2. to find the highest and lowest score in the subject.
3. to sort the marks in the ascending order
4. to count the number of students who scored more than 80.
i have tried to write it
there are certain errors
Code:
import java.io.*;
class MarksOfStudents1{
int marks[]={67,89,49,95,68,80,74,59,55,57,85,92,87,50,83};
for(int i=0; i<=14; i++)
{
System.out.println("Student marks are :"+sub_marks[i]);
}
void sumAverage(){
int sum=0;
double avg=0.0;
for(int i=0;i<14;i++)
{
System.out .println(marks[i]);
sum=sum+marks[i];
avg=sum/15;
System.out.println("marks of students= " +sum);
System.out.println("avg");
}
}
void maximumMminimum(){
System.out.println("Minimum value="+getMinValue(marks));
System.out.println("Maximum value=" + get max value (marks));
}
void sorting(){
for (int i=0;i<14;i++){
for (int j=i+1; j<15; j++){
if(marks[i]> marks[j]){
int x,y;
x=marks[i];
y=marks[j];
marks[i]=y;
marks[j]=x;
}
}
}
System.out.println("Array after sorting in ascending order");
System.out.println();
for (int i=0;i<14;i++)
System.out.println(marks[i]);
}
public static void main(String args[]){
MarksOfStudents ms =new MarksOfStudents();
}
}
can anyone complete it for me plz??
Last edited by UnrealEd; 01-12-11 at 05:08 AM.
Reason: fixed [code] tags
There's no point in giving you a proper working code, it's better to learn and understand what needs to be done to get the program working. If I just give you the code, you probably just copy-paste it (and then hand it over to your boss/colleagues). On the other hand, if you tell us what the errors are, I can guide you to the issue and help you fix it. It's way better to find a solution yourself than copy-paste one.
So, what are the errors?
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks