Write a Java program to accept name and total marks of "N" number of students in two single subscript array name[] and totalmarks[].
Calculate and print:
(i) The average of the total marks obtained by "N" number of students
[average= (sum of total marks of all the students)/N]
(ii) Deviation of each student's total marks with the average.
[deviation = total marks of a student- average]
Answers
Answered by
44
ANSWER:
import java.util.*;
class Student
{
int n, i, s=0;
double avg, d;
void display ()
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter number of students");
n=sc.nextInt();
String name[]= new String [n];
int totalmarks []= new int[n];
for(i=0;i<n;i++)
{
System.out.println("Enter name and total marks");
name[i]=sc.nextLine();
totalmarks[i]= sc.nextInt();
s=s+totalmarks [i];
}
avg=(double)s/n;
System.out.println("Average="+avg);
for(i=0;i<n;i++)
{
d=totalmarks [i] - avg;
System.out.println(name[i]+"Deviation is"+d);
}
}
}
Hope it helps...
Answered by
3
Explanation:
done see ...I will help
Attachments:
Similar questions