Computer Science, asked by saanvib13, 3 months ago

Write a Java program to initialize student name and 7 subject marks, calculate total ,
average and print details with proper messages.

Answers

Answered by mohammadadnan7
0

Answer:

import java.util.*;

class Student

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

String name;

double marks[]=new double[7];

double sum=0,avg;

System.out.println("Enter name and marks in 7 subject ");

name=sc.nextLine();

for(int i=0;i<7;i++)

{

marks[i]=sc.nextDouble();

sum=sum+marks[i];

}

avg=sum/7;

System.out.println("Name of the student : "+name);

System.out.println("Sum of the marks in 7 subjects : "+sum);

System.out.println("Average of marks in all 7 subjects : "+avg);

}

}

Similar questions