Computer Science, asked by kashvirathod2005, 8 months ago

The marks obtained by 50 students in a subject are tabulated as follows:- Name Marks ....... ....... Write a program to input the names and the marks of the students in the subject. Calculate and display:- i. The subject average marks ( subject average marks = subject total / 50 ) ii. The highest mark in the subject and the name of the student.

Answers

Answered by swagat18
28

Answer:

import java.util.*;

public class Marks

{

public static void main(String args)

{

Scanner sc=new Scanner(System.in);

String nm;

double mth,sci,eng,hist,hin,avg,hig;

System.out.println("Enter your name=") ;

nm=sc.nextLine() ;

System.out.println("Enter marks in Science, Maths, English, History, Hindi") ;

sci=sc.nextDouble();

mth=sc.nextDouble();

eng=sc.nextDouble();

hist=sc.nextDouble();

hin=sc.nextDouble();

avg=((sci+mth+eng+hist+hin)/50);

System.out.println("Name-"+nm);

System.out.println("Average="+avg);

sc.close();

}

}

I hope this helps, i wrote the answer as per the requirement of your question... mark brainliest and follow me

Answered by muskanjain2510
5

Answer:

import java.util.Scanner;

public class marks

{

public static void main(String args[]) {

final int TOTAL_STUDENTS = 50;

Scanner in = new Scanner(System.in);

String name[] = new String[TOTAL_STUDENTS];

int marks[] = new int[TOTAL_STUDENTS];

int total = 0;

for (int i = 0; i < name.length; i++) {

System.out.print("Enter name of student " + (i+1) + ": ");

name[i] = in.nextLine();

System.out.print("Enter marks of student " + (i+1) + ": ");

marks[i] = in.nextInt();

total += marks[i];

in.nextLine();

}

double avg = (double)total / TOTAL_STUDENTS;

System.out.println("Subject Average Marks = " + avg);

int hIdx = 0;

for (int i = 1; i < marks.length; i++) {

if (marks[i] > marks[hIdx])

hIdx = i;

}

System.out.println("Highest Marks = " + marks[hIdx]);

System.out.println("Name = " + name[hIdx]);

}

}

Similar questions